I know this question may have already been asked before, but I haven't found a solution that works for my case.
I'm trying to install tensorflow-gpu
, but it keeps returning the error:
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Past answers suggest it might have something to do with the compatability of tensorflow and CUDA.
When I run nvcc --version
, I get:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:07:04_CDT_2018
Cuda compilation tools, release 9.2, V9.2.148
I've already tried installing previous versions of tensorflow-gpu
, i.e. tensorflow-gpu==1.12.0
, tensorflow-gpu==1.8.0
, and tensorflow-gpu==1.4.0
. But what happens is the error becomes libcublas.so.9.0
or libcublas.so.8.0:
, depending on the version of tensorflow-gpu
.
Note that I've set LD_LIBRARY_PATH
environment variable to the following:
LD_LIBRARY_PATH=/usr/local/cuda-9.2/extras/CUPTI/lib64:/usr/local/cuda/lib64:/usr/local/nccl2/lib:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda-9.2/lib64/:/usr/local/cuda/lib64/
I'm not quite sure how to fix this. I have absolutely no trouble getting pytorch to work with GPU, but with tensorflow and keras, it's a lot of hassle. Any ideas?
Full error here:
Using TensorFlow backend.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
~/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in <module>
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
~/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
/usr/lib/python3.5/imp.py in load_module(name, file, filename, details)
241 else:
--> 242 return load_dynamic(name, filename, file)
243 elif type_ == PKG_DIRECTORY:
/usr/lib/python3.5/imp.py in load_dynamic(name, path, file)
341 name=name, loader=loader, origin=path)
--> 342 return _load(spec)
343
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-3d00d838479b> in <module>
----> 1 from keras import backend as K
2 K.tensorflow_backend._get_available_gpus()
~/.local/lib/python3.5/site-packages/keras/__init__.py in <module>
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
~/.local/lib/python3.5/site-packages/keras/utils/__init__.py in <module>
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.
~/.local/lib/python3.5/site-packages/keras/utils/conv_utils.py in <module>
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
~/.local/lib/python3.5/site-packages/keras/backend/__init__.py in <module>
87 elif _BACKEND == 'tensorflow':
88 sys.stderr.write('Using TensorFlow backend.\n')
---> 89 from .tensorflow_backend import *
90 else:
91 # Try and load external backend.
~/.local/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py in <module>
3 from __future__ import print_function
4
----> 5 import tensorflow as tf
6 from tensorflow.python.framework import ops as tf_ops
7 from tensorflow.python.training import moving_averages
~/.local/lib/python3.5/site-packages/tensorflow/__init__.py in <module>
22
23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25
26 try:
~/.local/lib/python3.5/site-packages/tensorflow/python/__init__.py in <module>
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 from tensorflow.python.tools import component_api_helper
~/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/home/jack/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/jack/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/jack/.local/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 "/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.
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.enter code here
EDIT: I think I may have found the root cause of the problem here. It's that the cuda folder is named cuda-9.2
and tensorflow is looking for cuda-9.0
. I'm not quite sure how to fix this though.