cuda、cudnn、cudatoolkit不匹配的解决方案

cuda与cudatoolkit不匹配

安装TensorFlow2.0 GPU版本后,检测是否支持GPU时tf.test.is_gpu_available()出现以下信息:

2019-11-19 02:52:53.934654: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcudart.so.10.0'; dlerror: libcudart.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda/lib64:
2019-11-19 02:52:53.934856: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcublas.so.10.0'; dlerror: libcublas.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda/lib64:
2019-11-19 02:52:53.935050: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcufft.so.10.0'; dlerror: libcufft.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda/lib64:

Out[3]: False

原因:TensorFlow2.0现在支持CUDA10.0,还不支持CUDA10.1,而我的Ubuntu上安装的是CUDA10.1(也正确安装了cuDNN)。现在只需要安装一个CUDA10.1就行。可以仿照安装pytorch时就自动安装cudatoolkit 10.1.243,无需再下载CUDA10.0的包,在Ubuntu上重新安装CUDA10.0,而是直接用conda安装cudatoolkit。因为我的TensorFlow是安装到独立的虚拟环境中的,故执行以下代码即可安装:

(tensorflow2) usr@ubuntu16:~$ conda install cudatoolkit=10.0

再conda list一下,发现cudatoolkit=10.0已安装到当前环境下:

测试一下:

In [1]: import tensorflow as tf
In [2]: tf.test.is_gpu_available()
Out[2]: True

cudatoolkit与cudnn不匹配

报错信息如下

Could not load dynamic library 'libcudnn.so.7'

解决方法

conda install -c anaconda cudnn

参考文献

解决Could not load dynamic library ‘libcudart.so.10.0’; dlerror: libcudart.so.10.0: cannot open

Could not load dynamic library 'libcudnn.so.7’解决方案 tensorflow

你可能感兴趣的:(TensorFlow,tensorflow,ubuntu,cuda)