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

When installing cudnn, after the installation, import tensorflow will have the error in the question,

This error is either caused by the configuration of environment variables or the establishment of cudnn connection.

1. Environmental variables

Add at the end of ~ /. Bashrc

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

export LD_ LIBRARY_ PATH=/usr/local/cuda/lib64${LD_ LIBRARY_ PATH:+:${LD_ LIBRARY_ PATH}}

export CUDA_ HOME=/usr/local/cuda

2. Cudnn connection establishment

 cd /usr/local/cuda/lib64

sudo rm -rf libcudnn.so libcudnn.so . 7 # delete the original version number, which is queried in cudnn / lib64

sudo ln -s libcudnn.so .7.0.5 libcudnn.so . 7 # generate a soft connection and pay attention to the version number you download

sudo ln -s libcudnn.so .7 libcudnn.so  

Sudo ldconfig # effective immediately

 

Read More: