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

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

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.


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!