Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: libcublas.so.9.0: cannot open shared object file

currently I have cuda 8.0 and cuda 9.0 installed in Gpu support system. I ran into this error while importing from keras module. It says like failed to load native tensorflow runtime. The error log which i received was:

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  During handling of the above exception, another exception occurred:  Traceback (most recent call last): File "Try1.py", line 11, in <module> from keras.models import Sequential File "/usr/local/lib/python3.5/dist-packages/Keras-2.0.9-py3.5.egg/keras/__init__.py", line 3, in <module> File "/usr/local/lib/python3.5/dist-packages/Keras-2.0.9-py3.5.egg/keras/utils/__init__.py", line 6, in <module> File "/usr/local/lib/python3.5/dist-packages/Keras-2.0.9-py3.5.egg/keras/utils/conv_utils.py", line 3, in <module> File "/usr/local/lib/python3.5/dist-packages/Keras-2.0.9-py3.5.egg/keras/backend/__init__.py", line 83, in <module> File "/usr/local/lib/python3.5/dist-packages/Keras-2.0.9-py3.5.egg/keras/backend/tensorflow_backend.py", 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 49, in <module> from tensorflow.python import pywrap_tensorflow File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 73, 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 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   Failed to load the native TensorFlow runtime. 

When I run nvcc --version, the cuda version returned is,

Cuda compilation tools, release 8.0, V8.0.61 

I read about some similar post but couldn't solve my issue. Mostly I think this is a clash between two cuda versions. Can anyone tell me how to solve this? Thanks in advance.

like image 976
arvind Avatar asked Jan 24 '18 17:01

arvind


2 Answers

You will need to update your LD_LIBRARY_PATH, so that it points to the /usr/local/cuda-9.0/lib64. Add the following line to your .bashrc file (or any other terminal you use)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64/ 
like image 197
layog Avatar answered Oct 01 '22 05:10

layog


The Tensorflow Binaries do not support Cuda 9.1 as of now. So the solution might be just installing Tensorflow from source.

I too had the above mentioned issue while I had installed Cuda 9.1+cuDNN 6 for Tensorflow and this is what worked for me.

https://devtalk.nvidia.com/default/topic/1026198/cuda-setup-and-installation/cuda-9-0-importerror-libcublas-so-8-0

Additionally, you have the following two options:

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

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

like image 34
daVincere Avatar answered Oct 01 '22 05:10

daVincere