4

I have been trying for a week now to rectify an issue I am having with importing tensorflow into python. twice now I have followed the ubuntu 16.04 install instructions for tensorflow. https://www.tensorflow.org/install/install_linux

when trying to import tensorflow this is the message that I get:

salvo@AMD ~ $ source ~/tensorflow/bin/activate bash
(tensorflow) salvo@AMD ~ $ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/salvo/tensorflow/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
   from tensorflow.python import *
   File "/home/salvo/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 51, in <module>
      from tensorflow.python import pywrap_tensorflow
File "/home/salvo/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
 File "/home/salvo/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/salvo/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/salvo/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.

the system is running Linux mint 18.1 python is 2.7

I am not experienced enough to understand the reference to "" or

Can somebody shed some light on this issue?

5
  • 1
    what do you get when you search for libcudnn.so.5? locate libcudnn.so.5 Commented Apr 29, 2017 at 21:35
  • I was able to follow the question well enough, but you might be able to get better responses if you indent the output from python four spaces so it appears as code blocks and linebreaks are preserved. I can't propose the edit from within the first post review interface Commented Apr 29, 2017 at 21:53
  • mgig I was not able to locate a libcudnn.so.5 however I was able to find a libcudnn.so.6 the output of locate libcudnn.so.6 is /home/salvo/Cuda/cudnn/cuda/lib64/libcudnn.so /home/salvo/Cuda/cudnn/cuda/lib64/libcudnn.so.6 /home/salvo/Cuda/cudnn/cuda/lib64/libcudnn.so.6.0.21 Commented Apr 29, 2017 at 22:25
  • Add that to your LD_LIBRARY_PATH environment variable, it's just not finding your CuDNN library. Commented Apr 29, 2017 at 22:49
  • Thank you David, could you give an explanation of what is going on so I understand for the future? I used the following commands to add the paths to the LD_LIBRARY_PATH: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/salvoCuda/cudnn/cuda/lib64/libcudnn.so export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/salvoCuda/cudnn/cuda/lib64/libcudnn.so.6 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/salvo/Cuda/cudnn/cuda/lib64/libcudnn.so.6.0.21 still getting the same error, I assume it is because '_pywrap_tensorflow_internal' is looking for libcudnn.so.5? Commented Apr 29, 2017 at 23:41

2 Answers 2

1

You need to have the following environment variables set like below - with the correct folders for your install. Copy the contents of your CUDNN folder to your cuda folder, so that all the required lib files are together. Most installation instruction have a symbolic link from /usr/local/cuda to the latest cuda version. Note that the variable is to the path not the file.

export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
Sign up to request clarification or add additional context in comments.

Comments

1

Thank you Puternerd, mgig, and Sam Hartman! I followed Puternerd's direction about the variable needing to be the PATH to the library not the file itself, so the command that did it was

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/salvo/Cuda/cudnn/cuda/lib64

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.