Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow: ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory

I have recently installed tensorflow-gpu using pip. But when I am importing it it is giving the following error:

ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory

I have gone through all the answers of stackoverflow related to this issue but none of them worked for me.

libcudnn.so.7 is present in both the following directories /usr/local/cuda/lib64 and /usr/local/cuda-9.0/lib64 .

Also, I have added the following path in my .bashrc file:

export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Please help me in resolving this

like image 998
shivank01 Avatar asked Jun 25 '18 08:06

shivank01


3 Answers

You are setting LD_LIBRARY_PATH in the wrong way, I would recommend to do it this way (which is kind of the standard):

export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
like image 88
Dr. Snoopy Avatar answered Nov 08 '22 16:11

Dr. Snoopy


You might need to download and install NVIDIA cuDNN.

Download it from https://developer.nvidia.com/rdp/cudnn-download (You have to register an account to download if you don't have). The runtime version is usually more stable than the developer version.

like image 28
biendltb Avatar answered Nov 08 '22 14:11

biendltb


Reinstalling CudNN-7.0.5, (make sure you pick the right version from the link below) fixed this for me. You'll need to log in to your Nvidia developer account to access the link. (If you don't have an Nvidia account, creating one is straight forward);

https://developer.nvidia.com/rdp/cudnn-archive

Installation instructions for CudNN; https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html

But I also encountered the following error;

Loaded runtime CuDNN library: 7.0.5 but source was compiled with: 7.4.2. CuDNN library major and minor version needs to match or have higher minor version in case of CuDNN 7.0 or later version. If using a binary install, upgrade your CuDNN library. If building from sources, make sure the library loaded at runtime is compatible with the version specified during compile configuration.

Therefore, I had to once again download and install the right CuDNN version, i used the information from the above error message and installed CuDNN 7.4.2 and this fixed all the errors and everything worked fine.

Good Luck!

like image 5
Sri Avatar answered Nov 08 '22 15:11

Sri