nvidia验证程序加载失败_更新Ubuntu内核后,无法加载NVIDIA驱动

Ubuntu内核自动升级会导致nvidia-smi失败,显卡驱动与内核版本不匹配。解决的两种思路,一是内核版本降级,二是更换与内核版本匹配的驱动。

一没有实验成功(可能是配置错误),所以按照二执行,参照网上大神的步骤,简单做一个 记录,以备后续遇到使用。

问题:

xxx@ubuntu: ~$ nvidia-smi

NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

解决:

进入/usr/src看到nvidia-418.xxx.xx文件夹,说明nvidia驱动版本是418.xxx.xx。根据网上的办法,使用以下命令:

1) sudo apt-get install dkms

2)sudo dkms install -m nvidia -v 418.xxx.xx(NVIDIA版本号)

如果报错,出现错误提示:
Bad return status for module build on kernel: 5.4.0-42-generic on Ubuntu18.04. NVIDIA-SMI failed.

Linux内核版本是5.4.0-42-generic,这个内核版本网上也说与许多版本驱动匹配,需要升级到440版本的NVIDIA驱动。

执行下面步骤安装更高版本的驱动。

3)sudo apt-get autoremove --purge nvidia-*

4)sudo apt-get install --reinstall linux-headers-$(uname -r)

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

6)sudo apt-get update

7)sudo apt-get install nvidia-driver-440

8)sudo reboot

其中5)会卡住,将5)6)更换为https://www.tok9.com/archives/480/的方法,来安装nvidia-driver-440。

注释:/etc/default/grab中=两边空格敏感,若需改不要随手空格。

参考:

1.https://blog.csdn.net/qq_34953750/article/details/107662693

2.https://www.tok9.com/archives/480/