Ubuntu 22.04 安装 NVIDIA 显卡驱动失败笔记

                     

贡献者: addis

1. 官网驱动安装失败

   因为 gcc 的版本是 11.2,但 kernel 编译 gcc 版本是 11.3,而这非常困难,参考子节 1

   首先到 Nvidia 官网下载 Linux 驱动。安装以后提示需要先禁止 nouveau 驱动才可以安装。安装包可以自动写入一个 /etc/modprobe.d/nvidia-installer-disable-nouveau.conf 文件来试图禁止。

代码 1:nvidia-installer-disable-nouveau.conf
# generated by nvidia-installer
blacklist nouveau
options nouveau modeset=0

   注意写入该文件后,如果显卡安装失败,那么重启以后就可能导致屏幕没有任何反应。但只要想办法把该文件删掉再次重启即可(例如用一个启动 U 盘)。

   另外 Nvidia 驱动安装包的日志会写进 /var/log/nvidia-installer.log

   安装包会提示这个

An alternate method of installing the NVIDIA driver was detected.
(This is usually a package provided by your distributor.) A      
  driver installed via that method may integrate better with your
  system than a driver installed by nvidia-installer.

  Please review the message provided by the maintainer of this alternate
  installation method and decide how to proceed:

Continue installation                        Abort installation

   ERROR: An error occurred while performing the step: "Building kernel modules". See /var/log/nvidia-installer.log for details.

2. apt 和 ubuntu-drivers 安装驱动失败

   失败原因: apt 在 trigger 的时候无法 load kernel,最可能是因为 kernel 编译器和当前编译器不一样。

   sudo add-apt-repository ppa:graphics-drivers/ppa

   /var/log/nvidia-installer.log:

   -> Kernel module compilation complete. ERROR: Unable to load the kernel module 'nvidia.ko'. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if another driver, such as nouveau, is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA device(s), or no NVIDIA device installed in this system is supported by this NVIDIA Linux graphics driver release.

   参考这个,推荐用 ubuntu-drivers tool。

图
图 1

                     

© 小时科技 保留一切权利