• Register
0 votes
66 views

Problem :

I have recently installed the cuda 8.0 and cuda 9.0 in the Gpu support system. I encountered the below error while importing from the keras module. It says it is unable to load the native tensorflow runtime. I have received the error log as below:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, 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: libcublas.so.9.0: cannot open shared object file: No such file or directory

If I run the nvcc --version, my cuda version returned is,

Cuda compilation tools, release 8.0, V8.0.61

Is it the clash between two cuda versions? Have anyone solved this before?

8 4 2
2,300 points

2 Answers

0 votes

Solution :

I also had faced this error sometimes back. If you want to fix your error then just follow the below procedure.

You will need to just update your LD_LIBRARY_PATH, to make it point to the /usr/local/cuda-9.0/lib64. To do that you need to add the below line to your .bashrc file or the any other terminal which you use.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64/

You can also try the below code
pip3 install --upgrade tensorflow-gpu==1.4
After typing above command in your terminal your tensorflow will downgrade it to 1.4.0. This bug is caused by the tensorflow 1.6.0.
5 2 1
4,980 points
0 votes

Solution:

You will require to update your LD_LIBRARY_PATH, hence that it points to the /usr/local/cuda-9.0/lib64. Include the following line to your .bashrc file (or any other terminal you usage)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64/

The Tensorflow Binaries do not support Cuda 9.1 as of currently. Hence, the resolution might be only installing Tensorflow from source.

I too had the above mentioned problem at the time I had installed Cuda 9.1+cuDNN 6 for Tensorflow and this is what performed for me.

Moreover, you have the following two options:

  1. CUDA 8.0 + Tensorflow - the most stable release of CUDA that performs with Tensorflow Binaries.

  2. CUDA 9.0 + Tensorflow - current CUDA version that Tensorflow Binaries are compatible with.

Attempt the following code

pip3 install --upgrade tensorflow-gpu==1.4

Afterwards you typing this command pip3 install --upgrade tensorflow-gpu==1.4 in the terminal, the tensorflow will downgrade to 1.4.0. This bug happened by tensorflow 1.6.0.

Tensorflow version >= 1.5 requires CUDA version > 8.0. Hence, in case you have CUDA version 8.0, you can downgrade your tensorflow version to 1.4.

pip install tensorflow-gpu==1.4

You're attempting to make tensorflow-gpu 1.4, which is too old to be compatible with CUDA 9.1.

  1. You can attempt to make a symbolic link to force the system to use CUDA 9.1, though it's not sure it'll succeed

  2. You can follow this tutorial which explains how to easily install CUDA 9.0 on Ubuntu 16.04.

  3. In case it still doesn't perform and that you trully need to attempt to install Tensorflow with CUDA 9.1, you can attempt to install CUDA, CUDNN and NCCL sources from the NVIDIA site, and then simulate the way these packages would have been installed from ppa.

At one time you've downloaded the tar packages, type the following to configure CUDA:

sudo mkdir -p /usr/local/cuda /usr/local/cuda/extras/CUPTI /usr/local/cuda/nvvm
sudo ln -s /usr/bin /usr/local/cuda/bin
sudo ln -s /usr/include /usr/local/cuda/include
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/local/cuda/lib64
sudo ln -s /usr/local/cuda/lib64 /usr/local/cuda/lib
sudo ln -s /usr/include /usr/local/cuda/extras/CUPTI/include
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/local/cuda/extras/CUPTI/lib64
sudo ln -s /usr/lib/nvidia-cuda-toolkit/libdevice /usr/local/cuda/nvvm/libdevice

Thereafter you can either download cuDNN and NCCL from source and configure them in the similar fashion as above , or download their .deb package and view in case the installation performs currently. In case it doesn't, then attempt to install from source.

There is an other problem concerned to this. In case you've installed Cuda 9.1 or 9.0 in your lib64 folder you will view that the links come from another folders and it can have a file like this libcublas. Hence,.9 which is originally the similar file without .0  part. I think you can only create another link to libcublas.so.9. -> libcublas.so.9.0.

The issue is concerned to the path of intealled cuda. You require to tell where the files are located by including global environment variable. 

LD_LIBRARY_PATH = /usr/local/cuda/lib64:$LD_LIBRARY_PATH

You can include this into your .bash_profile to let it run globaly.

10 6 4
31,120 points

Related questions

0 votes
0 answers 153 views
153 views
Problem : I have installed Cuda 10.1 and cudnn on Ubuntu 18.04 for the first time and it seems to be installed properly as when I type nvcc and nvidia-smi I am getting proper response. I have also installed tensorflow using following command: user:~$ sudo ... solutions. Include the entire stack trace above this error message when asking for help. Am I missing something? How to resolve this issue?
asked Nov 27, 2019 AbhijitJ 38.6k points
0 votes
1 answer 69 views
69 views
Problem : I am very new to tensorflow-gpu, I want to use the tensorflow-gpu on my system. I have already tried to reinstall tensorflow-gpu many times but still it shows me the following error.If I use the tensorflow-cpu then it works correctly. Please Note: I ... ) ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory Can somebody help me in fixing above error ?
asked Feb 19 mphil 2.3k points
0 votes
1 answer 166 views
166 views
Problem : I have installed Cuda 10.1 and cudnn on Ubuntu 18.04 for the first time and it seems to be installed properly as when I type nvcc and nvidia-smi I am getting proper response. I have also installed tensorflow using following command: user:~$ sudo ... solutions. Include the entire stack trace above this error message when asking for help. Am I missing something? How to resolve this issue?
asked Nov 27, 2019 alecxe 7.5k points
0 votes
1 answer 1.2K views
1.2K views
Problem : I am facing following error : ImportError: libcuda.so.1: cannot open shared object file: No such file or directory Failed to load the native TensorFlow runtime. Above error comes up when I tried to import the tensorflow. Is there anybody who has faced this error before and know the solution on it?
asked Dec 10, 2019 alecxe 7.5k points
0 votes
1 answer 191 views
191 views
Problem : I am building the TensorFlow from the source code. The build appears to succeed; but, when my TensorFlow program invokes the import tensorflow, one or both of the following errors starts appearing: · ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory · ImportError: libcudnn.5: cannot open shared object file: No such file or directory
asked Dec 9, 2019 alecxe 7.5k points