无法连接NVIDIA驱动: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

重启服务器之后就出现连接不上NVIDIA驱动的情况。这个时候tensorflow还是可以运行的,但只是在用cpu跑。安装gpu版的TensorFlow时,也显示已安装。

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.

我们在终端输入 nvcc -V 发现驱动也在。

在这里插入图片描述

这就很魔性了。。。查找了很多方法之后,发现下面这个最简便,只需要两步,而且还不用重启,哈哈。

step1:sudo apt-get install dkms

step2: sudo dkms install -m nvidia -v 410.79

再次输入nvidia-smi时,你熟悉的界面就会回来啦。

在这里插入图片描述

(虽然使用率显示为99%,但并不影响我们使用)

其中step2 中的410.79是NVIDIA的版本号,当你不知道的时候,进入/usr/src目录中,可以看到里面有nvidia文件夹,后缀就是其版本号

cd /usr/src

在这里插入图片描述

OK,到此我们就轻松愉快的解决了这个问题。(Yeah!)

另:怎么查看TensorFlow是gpu版本还是cpu版本

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章