重启服务器之后就出现连接不上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.
1 在终端输入 nvcc -V
驱动也在
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61
解决办法只需要两步,不用重启
step1:sudo apt-get install dkms
step2: sudo dkms install -m nvidia -v 410.73
再次输入nvidia-smi
时,回归正常。
其中step2 中的410.73是NVIDIA的版本号,当不知道版本号时,进入/usr/src目录中,可以看到里面有nvidia文件夹,后缀就是其版本号
cd /usr/src
另:怎么查看TensorFlow是gpu版本还是cpu版本
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
参考 https://blog.youkuaiyun.com/hangzuxi8764/article/details/86572093