CUDA安装成功后测试Sample的时候报错(问题解决)

在我们安装好了CUDA后,迫不及待的想试试CUDA自带的Sample。

cd /usr/local/cuda-9.0/samples/1_Utilities/deviceQuery
make
sudo ./deviceQuery

之后出现以下的错误:

$ ./deviceQuery
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 30
-> unknown error
Result = FAIL

解决办法:

检查NVIDIA驱动是否安装好了

$ nvidia-smi

出现下列信息就说明没有装好

$ 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.

这个时候我们就重新把nvidia驱动装好,那么问题就解决了。

需要注意一点,在安装CUDA的时候我们把GCC和G++降级了,现在如果想安装nvidia驱动的话就需要先把GCC和G++升级,所以执行下面语句:

sudo apt-get purge gcc

sudo apt-get purge g++

sudo apt-get install gcc

sudo apt-get install g++

然后就可以正式安装nvidia驱动了,详细安装过程:https://blog.csdn.net/qq_41481731/article/details/86640170

安装好了nvidia驱动之后,在运行Sample,如果出现下图相似的图,就说明安装好了

130537_6sIP_614348.png

原文地址:https://www.cnblogs.com/Leozi/p/13281214.html