ubuntu 22.04 安装驱动可能遇到的坑

1. 第一个坑 【gcc版本不匹配】

请确认你的gcc版本是不是12的,11是编译不通过的。

一般在最后编译时报错,在/var/log/nvidia-installer.log日志中可以看到以下字样

Warning: Compiler version check failed:

The major and minor number of the compiler used to
compile the kernel:

x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38

does not match the compiler used here:

cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


It is recommended to set the CC environment variable
to the compiler that was used to compile the kernel.

To skip the test and silence this warning message, set
the IGNORE_CC_MISMATCH environment variable to "1".
However, mixing compiler versions between the kernel
and kernel modules can result in subtle bugs that are
difficult to diagnose.

*** Failed CC version check. ***

2. 没有找不到 gcc 或者cc

cd /usr/bin/
ls -al | grep gcc

去到/usr/bin目录下查看是否有gcc文件,如果只有gcc-12,需要创建软链接。

sudo ln -s /usr/bin/gcc-12 /usr/bin/gcc
sudo ln -s /usr/bin/gcc /usr/bin/cc

3.没有cc文件,报错如下

 ERROR: The CC sanity check failed:

         The C compiler '/usr/bin/cc' does not appear to be able to
         create object files.  Please make sure you have
         your Linux distribution's libc development package
         installed and that '/usr/bin/cc' is a valid C compiler
         name.

先检查cc软链接是否存在,可以参考坑2。

再去看看/usr/lib/gcc/x86_64-linux-gnu/12/目录下是否有cc1文件.

  • 12
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
为了在Ubuntu 22.04安装NVIDIA驱动程序,可以采用以下步骤: 1. 首先,访问NVIDIA官方网站并下载适用于Ubuntu 22.04的最新驱动程序。确保选择正确的驱动程序版本以适配您的显卡型号。 2. 在安装驱动程序之前,您需要禁用开源驱动程序nouveau。可以通过编辑GRUB引导选项来实现。打开终端并输入以下命令以编辑GRUB配置文件: ``` sudo nano /etc/default/grub ``` 在打开的文件中,找到名为GRUB_CMDLINE_LINUX_DEFAULT的行,将其修改为: ``` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nouveau.modeset=0" ``` 保存并关闭文件。然后运行以下命令更新GRUB配置: ``` sudo update-grub ``` 重新启动计算机以使更改生效。 3. 在登录界面,按Ctrl+Alt+F3切换到虚拟终端。 4. 在虚拟终端中,使用以下命令停止图形界面: ``` sudo service gdm stop ``` 5. 安装NVIDIA驱动程序。进入您下载驱动程序的目录,并执行以下命令(将驱动程序文件名替换为您下载的实际文件名): ``` sudo chmod +x <驱动程序文件名> sudo ./<驱动程序文件名> ``` 按照屏幕上的提示完成驱动程序的安装。 6. 安装完成后,重新启动计算机: ``` sudo reboot ``` 这将使新的NVIDIA驱动程序生效。 再次强调,这些步骤是在Ubuntu 22.04 LTS下测试过的,但请记住,不同的硬件配置和驱动程序版本可能会有所不同。在安装过程中,如果遇到任何问题,可以参考、和中提到的其他方法和解决方案。 希望对您有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值