Search code examples
pythonpython-3.xtensorflowcudnn

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


Solution

  • 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