文章目录

环境

Ubuntu16.04
Nvidia 384
CUDA 8.0
cuDNN 5

错误

TensorFlow、CUDA、cuDNN的版本关系我时常懵懵的,经常出现各种不支持的情况,比如今天安装了TensorFlow1.10.1,报错:ImportError: libcudnn.so.7: cannot open shared object file: No such file or dictionary

错误缘由

google了一圈发现, 问题出在 TensorFlow 1.10.1-gpu 是基于cuDNN7,需要的也就是libcudnn.so.7了。

解决方案:

Just download cuDNN v6 and follow the steps (Tested on Ubuntu 16.04, CUDA toolkit 9.0 ) https://developer.nvidia.com/cudnn

Download cuDNN v7.2.1 (August 7, 2018), for CUDA 9.2

Download cuDNN v7.2.1 (August 7, 2018), for CUDA 9.0

Download cuDNN v7.2.1 (August 7, 2018), for CUDA 8.0

$ tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz 
$ sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include 
$ sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64 
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Now set Path variables

$ vim ~/.bashrc 

翻到最底部加上:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64" 
export CUDA_HOME=/usr/local/cuda