NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver.


问题描述

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


原因分析:

     我的显卡驱动是之前装好了的,上次遇到这个问题重装了个驱动就好了,不可能每次都要通过重装驱动解决问题。于是上网找答案,可能是由于内核版本自动升级导致了显卡驱动不匹配导致的。
      开机启动项进入较老的显卡驱动版本运行nvidia-smi可以正常显示,通过搜索问题不停尝试排查发现这就是内核版本的问题。


解决方案:

可使用命令查看当前系统内核版本  

uname -r

这是我现在使用的内核版本(已经是更换成功的了)

查看系统下面有的内核版本,确保有自己可用的,没有的话还需要安装内核

grep gnulinux /boot/grub/grub.cfg

NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver._第1张图片

我这里原来是5.4.0-128-generc,复制我们要使用的内核版本ID

修改配置文件

sudo gedit /etc/default/grub

根据上面得到的内核版本修改我们的配置文件

GRUB_DEFAULT="gnulinux-advanced-d2feafa4-147a-414f-a39c-bb1577bbcdc5>gnulinux-5.4.0-110-generic-advanced-d2feafa4-147a-414f-a39c-bb1577bbcdc5"

将原来的 GRUB_DEFALUT=0替换成下图即可。(不要掉了双引号)

NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver._第2张图片

最后完成之后别忘了保存,最后更新一下grub

sudo update-grub 

重启再次输入

nvidia-smi 

 成功!!NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver._第3张图片

 查看内核版本也会发现,已经是我们指定的内核版本了!

注:本文过程参考源链接:linux ubuntu20.04切换系统内核_湖北吉秀软件官方博客的博客-CSDN博客_ubuntu20切换内核

你可能感兴趣的:(python)