sudo ldconfig /usr/local/cuda/lib64. Check here for more details and more information." /> sudo ldconfig /usr/local/cuda/lib64. Check here for more details and more information. />

Tensorflow: Error when trying to import tensorflow: libcudnn.so.5: No such file or directory

Introduction

This solution is for the opensource project from google tensorflow. The solution we provide will work for Ubuntu and simular linux distributions.

The problem

When you try to import tensorflow on your python project you get the following error:

File "", line 1, in 
File "/home/tutorialstechnology/anaconda2/lib/python2.7/site-packages/tensorflow/init.py", line 24, in 
from tensorflow.python import *
File "/home/tutorialstechnology/anaconda2/lib/python2.7/site-packages/tensorflow/python/init.py", line 72, in 
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/tutorialstechnology/anaconda2/lib/python2.7/site-packages/tensorflow/python/init.py", line 61, in 
from tensorflow.python import pywrap_tensorflow
File "/home/tutorialstechnology/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in 
_pywrap_tensorflow = swig_import_helper()
File "/home/tutorialstechnology/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory

Verification

Make sure have the valid cuDNN version for your tensorflow installation. You can use cuDNN 6.0 with version 1.3. Older version will require R5.1.

The stack trace above suggest that you are using version R5, you could try to update tensorflow to 1.3 and use cuDNN 6.0. If you don't want to upgrade now check the following solutions.

Solution 1

If you are still having issues check to execute ldconfig:

sudo ldconfig /usr/local/cuda/lib64

Solution 2

You should try to reinstall cuDNN