VirtualEnv tensorflow with Nvidia GPU : cuda-9.0-vs-cuda-8.0, cuDNN-7.0-vs-cuDNN-6.0 - tensorflow

Today I installed tensorflow using the RTFM tensorflow dot org install linux,
I installed the VirtualEnv + Python3 + CPU and tested tensorflow Hello World, which worked fine.
Then I went on the nvidia path (GPU GTX 970) to install VirtualEnv + Python + GPU. RTFM (docs dot nvidia dot com cuda cuda-installation-guide-linux index dot html) , cuda-9.0, cuDDN 7, all PATH's are okay, .bashrc up-to-date, printenv LD_LIBRARY_PATH ok.
My GPU has been ok with the cuda scripts deviceQuery and bandwitdhTest. All post-installation-actions from the Nvidia checklist passed.
When I run Hello World in VirtualEnv+Python3+GPU, code below is what I get (cliffnote : tensorflow wants to use some cudalibrary-8.0 from the /usr/local/cuda-9.0/lib64 which is a 9.0 directory. I tried to add a symlink so cudalibrary-8.0 points to 9.0, but then I get the same message with another cudalibrary... doing this trick for all the cuda libraries is not what I call a fix ;-) )
alexandre#Martin-2:~/Documents/Ordinateur/VirtualEnv$ source tensorflow_py3_gpu/bin/activate
(tensorflow_py3_gpu) alexandre#Martin-2:~/Documents/Ordinateur/VirtualEnv$ python
Python 3.5.2 (default, Sep 14 2017, 22:51:06) [GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> # Python
... import tensorflow as tf
Traceback (most recent call last):
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
Last line above is about the cudalibrary-8.0 that obviously is NOT in the list of the cudalibrary-9.0. Below is the rest of it.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/alexandre/Documents/Ordinateur/VirtualEnv/tensorflow_py3_gpu/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https tensorflow dot org slash install slash install_sources hashtag common_installation_problems for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.
>>> hello = tf.constant('Hello, TensorFlow!')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'tf' is not defined
>>> sess = tf.Session()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'tf' is not defined
>>> print(sess.run(hello))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sess' is not defined
>>> quit()
(tensorflow_py3_gpu) alexandre#Martin-2:~/Documents/Ordinateur/VirtualEnv$ deactivate`
--
Next day update
Not so clean fix : Create a link in /usr/local/cuda/lib64/ for every library with the wrong number version, linked to the right number version.
alexandre#Martin-2:/usr/local/cuda/lib64$ sudo ln -s libcurand.so.9.0 libcurand.so.8.0
I did this with five cuda libraries (libcusolver, libcublas, libcudart, libcurand, libcufft) and with the cuDNN library libcudnn (version 6 --> version 7).
Hello world! tensorflow worked... but if someone can tell me why tensorflow calls cuda-8.0 and cuDDN-6.0 libraries when I only installed cuda-9.0 and cuDDN-7.0, you're very welcome.
[SOLVED... OR NEARLY] UPDATE
I found https://github.com/tensorflow/tensorflow/issues/12052 that explains almost it all.
Cliffnote :
tensorflow-1.3 uses cuda-8.0 and cuDNN-6.0 (this is why these libraries are linked explicitly when I run tensorflow). I got tricked on the nvidia site that made me download the cuda-9.0 and cuDNN-7.0 versions, which will not be implemented in tensorflow-1.3.
tensorflow-1.4 will work with the cuda-9.0 and cuDNN-7.0 versions. tensorflow-1-4 may be available sometime in October 2017 (or anytime soon, check the link above).

Have you tried
sudo apt install cuda-8-0
?
It should download packages from http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604
Along with installing cudnn6 (the same way I installed cudnn7), it worked for me.

Related

How to downgrade to cuda 10.0 in arch linux?

I want to downgrade my cuda 10.1 to cuda 10.0 in arch linux as tensorflow requires cuda 10.0 only.
I installed tensorflow on CUDA 10.1 in arch Linux but I didn't know tensorflow-gpu needs CUDA 10.0 or lesser.
I tried tried symlinking the required 10.0 libraries with new 10.1 libraries but it didn't work.
Whenever I try to import tensorflow in python console error shows up that 'libcublas.so.10.0' not found.
So I found out that I can only run tensorflow on CUDA 10.0 so now I want to downgrade my CUDA. But I have no Idea how to do that in arch Linux.
Every time I run import tensorflow it gives this error.
Traceback (most recent call last):
File "/home/techievin/.local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/techievin/.local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/techievin/.local/lib/python3.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)
File "/usr/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/lib/libcublas.so.10.0: version `libcublas.so.10.0' not found (required by /home/techievin/.local/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/techievin/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/techievin/.local/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/techievin/.local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/techievin/.local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/techievin/.local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/techievin/.local/lib/python3.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)
File "/usr/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/lib/libcublas.so.10.0: version `libcublas.so.10.0' not found (required by /home/techievin/.local/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so)
Failed to load the native TensorFlow runtime.
pacman -S cuda=="10.0" is not working.
I searched everywhere but couldn't find any proper answer for arch Linux to downgrade to CUDA 10.0
Download cuda 10.0 package from here: http://archlinux.arkena.net/archive/packages/c/cuda/cuda-10.0.130-2-x86_64.pkg.tar.xz
Install package sudo pacman -U cuda-10.0.130-2-x86_64.pkg.tar.xz
I've solved this issue by using yay. With yay you can install older versions of cuda and cudnn. In my experience this is faster than downloading from archive.org.
Install yay on Arch:
pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Search for the version you need:
yay -Ss cuda
yay -Ss cudnn
At the moment of writing this answer I needed to downgrade from cuda 11.2 to 11.0. So I installed specific versions:
pacman -R cuda cudnn
yay -S cuda-11.0 cudnn8-cuda11.0
For me, Tensorflow worked smoothly after downgrading.
I'm facing the same issue and have to re-apply the method I used when I was using my old gtx670:
Downgrade the cuda package
Prevent it from being upgraded
keep in mind that specific Cuda versions need specific nvidia drivers.
Just have a look at the compatibility matrix and eventually prevent also the drivers from upgrading.

How to fix 'ImportError: DLL load failed: The specified procedure could not be found.' while importing tensorflow-gpu?

I cannot import tensorflow-gpu==1.13.1 on python 3.6.0.
What i have already done:
Nvidia's drivers (i have GEFORCE 840M which is cuda supported with compute capability 5.0).
I installed Visual Studio 2017 Professional (did not select any specifications in workload).
I installed CUDA 10.1 (was having issues with Visual studio integration so i disabled it during the installation).
I pasted Cudnn 7.5.0 onto cuda's folders.
Restarted.
Pip installed tensorflow-gpu==1.13.1 on python 3.6.0.
but then i cannot import tensorflow at all it shows the error below.
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>>>
Goal:
Obviously being able to import tensorflow and to import keras from the tensorflow library.
In my case this was an issue with detecting the correct CUDA Toolkit/cuDNN version with tensorflow-gpu==1.13.1.
After spending 2 hours on this I installed CUDA Toolkit 10.0 and set TF_CUDA_VERSION environment variable explicitly to 10 in the user env settings (Windows 10).

Tensorflow-alpha-gpu issue ImportError: DLL load failed: The specified module could not be found

I previously had cuda9.0_0 and cudnn7.1.4, I wanted to run tf-alpha in gpu,from this tf guide:https://www.tensorflow.org/install/gpu I found I need cuDNN SDK (>= 7.4.1) and cuda10.so I uninstalled previous versions from control panel and installed Cuda compilation tools, release 10.1, V10.1.105.So, I should have imported tf succesfully,but not,I got the error.
And if I had
conda list cudnn
I got
# packages in environment at F:\Anaconda:
#
# Name Version Build Channel
cudnn 7.1.4 cuda9.0_0 anaconda
Though I installed cuda 10 and cudnn succesfully verified by running
nvcc --version
I have anaconda installed and had previous cuda and I used tf 1.12.0 gpu ago and my gpu is nvidia 1050ti
import tensorflow as tf
I expected it to import tensorflow 2.0 alpha gpu version
The error I got:
Traceback (most recent call last):
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname,
description)
File "F:\Anaconda\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "F:\Anaconda\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:\Anaconda\lib\site-packages\tensorflow\__init__.py", line 27, in
<module>
from tensorflow._api.v2 import audio
File "F:\Anaconda\lib\site-packages\tensorflow\_api\v2\audio
\__init__.py", line 8, in <module>
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "F:\Anaconda\lib\site-packages\tensorflow\python\__init__.py", line
49, in <module>
from tensorflow.python import pywrap_tensorflow
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname,
description)
File "F:\Anaconda\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "F:\Anaconda\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
my python version is 3.6.6
Note:
TensorFlow Version >= 1.13 requires CUDA 10.0 and TensorFlow Version < 1.13 (till TF 1.5) requires CUDA 9.0.
See Software requirements to know more https://www.tensorflow.org/install/gpu#software_requirements
Also requires NVIDIA® GPU card with CUDA® Compute Capability 3.5 or higher.
See Hardware requirements to know more
https://www.tensorflow.org/install/gpu#hardware_requirements
Hope this helps.

Tensorflow: ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

I'm having problems in importing tensorflow in python3:
>>> import tensorflow as tf
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcusolver.so.8.0: 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.
I am using Nvidia drivers version 381.09 beta, as version 375 has this bug: https://askubuntu.com/questions/896221/strange-artifacts-along-window-borders-after-waking-computer-from-sleep-mode?noredirect=1&lq=1
I have install CUDA 8.0 and cuDNN-v6.0:
rharish#rharish-GL552VW:~$ cd /usr/local
rharish#rharish-GL552VW:/usr/local$ ls
bin cuda etc include man share
computecpp cuda-8.0 games lib sbin src
Also, libcusolver.so.8.0 exists in /usr/local/cuda/lib64/:
libcusolver.so.8.0 in 'ls' output
I have uninstalled and reinstalled CUDA, cuDNN, and built tensorflow from sources. This problem has been occuring since updating the Nvidia drivers to version 381.09 beta. Any help?
Found the solution:
I reinstalled nvidia-381, CUDA-8.0 (using the runfile) and cuDNN 6.0. Then I added the following in my .bashrc:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64/
No need for reinstallation. Install nvidia-cuda-dev:
sudo apt install nvidia-cuda-dev
Install cuDNN (which you download from https://developer.nvidia.com/cudnn), and set LD_LIBRARY_PATH accordingly (to cuda/lib64).
You could be having this problem if you installed the latest version of CUDA (9.0). If this is the case, you'll have the libcusolver.so.9.0 file or directory on your computer, but not 8.0, so python can't find it to import. Tensorflow doesn't yet support CUDA 9.0 (as of Oct 18th 2017).
To fix this, install CUDA 8.0, which can be found here. You can find all their legacy releases at the bottom of the main download page.
I faced this error due to incompatibility between Tensorflow version with CUDA.
I had tensorflow_gpu-1.3.0, CUDA 9 and cuDNN 7 which are incompatible as per this https://www.tensorflow.org/install/source#tested_build_configurations
so I uninstalled tensorflow_gpu-1.3.0 and installed tensorflow_gpu-1.5.0 and it worked fine
In addition to having the paths correctly set, the version of Tensorflow you have installed must be compatible with the CUDA driver version you have in your system otherwise it won't work.
See the link

ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

I am trying to use tensorflow-gpu on my system. I have re-installed it many times, it gives the error give below. But when I use tensorflow-cpu it works fine. I have cuda 8.0 toolkit installed and cudnn 5.1.
Traceback (most recent call last):
File "finetune.py", line 17, in <module>
import tensorflow as tf
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/saurabh/code/env/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/saurabh/code/env/local/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: libcudart.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
If changing your path variable does not work, running the following in your terminal is what usually solves this for me:
sudo ldconfig /usr/local/cuda/lib64
(sometimes cuda may need to be something like cuda-8.0, depending on your installation)
The problem is that you don't have environment variable CUDA_HOME set. If you think you have CUDA installed, then you need to make sure that the above environment variable is set prob=perly and contains address of the CUDA installation directory where all share libraries are located.
export CUDA_HOME=/CUDA/installation/path
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64"
sudo ldconfig /usr/local/cuda/lib64
Works for me.
Please refer this link for more information.
https://github.com/tensorflow/tensorflow/issues/5343