1. 程式人生 > >TensorFlow:ImportError: libcudnn.so.*: cannot open shared object file: No such file or dictionary

TensorFlow:ImportError: libcudnn.so.*: cannot open shared object file: No such file or dictionary

環境:

  • Ubuntu16.04
  • Nvidia 384
  • CUDA 8.0
  • cuDNN 5

錯誤

TensorFlow、CUDA、cuDNN的版本關係小白我時常懵懵的,經常出現各種不支援的情況,比如今天安裝了TensorFlow1.4,報錯:ImportError: libcudnn.so.6: cannot open shared object file: No such file or dictionary

錯誤緣由

google了一圈發現, 問題出在 TensorFlow 1.4-gpu 是基於cuDNN6,需要的也就是libcudnn.so.6了。

解決方案:

  • Just download cuDNN v6 and follow the steps (Tested on Ubuntu 16.04, CUDA toolkit 8.0 )https://developer.nvidia.com/cudnn
    $ 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