一.问题出现
在使用了apt-get update命令之后,出现
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver.
Make sure that the latest NVIDIA driver is installed and running
二.问题分析
问题在于更新内核版本与显卡驱动不适配,服务器的cuda版本为10.2.官网显示适配的内核是4.15.0.gcc是7.3.0
而在更新后查看cat /proc/version后可以看到内核版本为
三.问题解决
1.版本内核回退
查看系统中存在的内核版本
sudo dpkg --get-selections | grep linux
系统中应该是存在旧版本的,如果没有4.15就自己安装一个
sudo apt-get install linux-headers-4.4.0-98-generic linux-image-4.15.0-72-generic
修改etc/default/grub中的内容:GRUB_DEFAULT,默认为0,更改为要设置的内核:
GRUB_DEFAULT='Advanced options for Ubuntu>Ubuntu, with Linux 4.15.0-72-generic'
更新设置:
sudo update-grub
重启系统选择高级模式,查看内核版本是否回退成功:
uname -r
到这里就已经将版本回退,并且可以使用了,以下为可选选项:
查看系统中存在的内核版本
sudo dpkg --get-selections | grep linux
删除其他不需要的内核,install状态采用第一条命令,deinstall采用第二条命令
sudo apt-get remove linux-headers-[版本号]
sudo dpkg -P linux-image-[]版本号]-generic
更新grub:
sudo update-grub
为一劳永逸,直接禁止内核的更新,防止再出错误:
sudo apt-mark hold linux-headers-4.15.0-72 \
linux-headers-4.15.0-72-generic \
linux-image-4.15.0-72-generic \
linux-modules-4.15.0-72-generic \
linux-modules-extra-4.15.0-72-generic
echo "linux-headers-4.15.0-72 hold" | dpkg --set-selections
echo "linux-headers-4.15.0-72-generic hold" | dpkg --set-selections
echo "linux-image-4.15.0-72-generic hold" | dpkg --set-selections
echo "linux-modules-4.15.0-72-generic hold" | dpkg --set-selections
echo "linux-modules-extra-4.15.0-72-generic hold" | dpkg --set-selections
2.更新显卡驱动适配新的内核
没有实际操作,可以按照别人的博客试一试 https://zhuanlan.zhihu.com/p/167839204
参考了下面这些博客 感谢大佬们
ubuntu更新后显卡驱动失效解决方案
ubuntu内核版本回退,显卡驱动降级,重装显卡驱动和cuda,cudnn
Ubuntu18.04自动升级内核后降级
Ubuntu系统—系统驱动丢失、Kernel内核卸载、禁止更新