Tensorflow: ImportError: libcudnn.so.7: cannot ope

2020-06-09 04:12发布

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

5条回答
啃猪蹄的小仙女
2楼-- · 2020-06-09 04:36

The reason is that some libraries are missing. Try installing

sudo apt install libcudnn7
查看更多
叛逆
3楼-- · 2020-06-09 04:37

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!

查看更多
孤傲高冷的网名
4楼-- · 2020-06-09 04:42

FWIW is interested I created a shell script which installs different CUDA versions in Debian which can be easily ported to Ubuntu:

查看更多
Juvenile、少年°
5楼-- · 2020-06-09 04:49

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
查看更多
疯言疯语
6楼-- · 2020-06-09 04:50

you add the following path in your .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


export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
查看更多
登录 后发表回答