ubuntu关机开机后显卡挂了:报错NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. M...

傻电脑每次关机后开机显卡几乎都要挂,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.
然后就要重装驱动,就很烦。就要执行如下操作(而且是要切到htty下面(ctrl+alt+f1(这里可以到f6好像,f7切回桌面)):

 sudo service lightdm stop
 sudo ./NVIDIA-Linux-x86_64-410.78.run --no-opengl-files -a -s 
sudo service lightdm start

今天终于受不了了,所以就查了一下有没有其他的解决方案,然后就愉快的解决啦。
nvcc -V 没报错 说明cuda还是在的
whereis nvidia 显示nvidia: /usr/lib/nvidia /usr/share/nvidia /usr/src/nvidia-410.78/nvidia
查了一下,应该是由于内核版本与安装驱动时的版本不匹配造成的。
解决方案:

sudo apt-get install dkms #DKMS全称是Dynamic Kernel Module Support,它可以帮我们维护内核外的这些驱动程序,在内核版本变动之后可以自动重新生成新的模块。
sudo dkms install -m nvidia -v 410.78 #410.78是安装驱动的版本

完美解决

dkms status 显示
没有执行sudo dkms install -m nvidia -v 410.78之前
bbswitch, 0.8, 4.15.0-72-generic, x86_64: installed
bbswitch, 0.8, 4.15.0-74-generic, x86_64: installed
bbswitch, 0.8, 4.4.0-171-generic, x86_64: installed
之后
bbswitch, 0.8, 4.15.0-72-generic, x86_64: installed
bbswitch, 0.8, 4.15.0-74-generic, x86_64: installed
bbswitch, 0.8, 4.4.0-171-generic, x86_64: installed
nvidia, 410.78, 4.15.0-74-generic, x86_64: installed

nvidia-smi


推荐阅读更多精彩内容