ImportError:libcublas.so.9.0:无法打开共享库文件
keras
python-3.x
tensorflow
23
0

目前,我在Gpu支持系统中安装了cuda 8.0和cuda 9.0。从keras模块导入时遇到此错误。它说好像无法加载本机tensorflow运行时。我收到的错误日志是:

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.

当我运行nvcc --version时,返回的cuda版本是,

Cuda compilation tools, release 8.0, V8.0.61

我读过一些类似的文章,但无法解决我的问题。通常,我认为这是两个cuda版本之间的冲突。谁能告诉我如何解决这个问题?提前致谢。

参考资料:
Stack Overflow
收藏
评论
共 3 个回答
高赞 时间 活跃

Tensorflow Binaries目前不支持Cuda 9.1。所以解决方案可能只是从源代码安装Tensorflow。

在为Tensorflow安装Cuda 9.1 + cuDNN 6时,我也遇到了上述问题,这对我有用。

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

此外,您有以下两种选择:

  1. CUDA 8.0 + Tensorflow-与Tensorflow Binaries一起使用的最稳定的CUDA版本。

  2. CUDA 9.0 + Tensorflow-Tensorflow Binaries兼容的最新CUDA版本。

收藏
评论

您将需要更新LD_LIBRARY_PATH ,使其指向/usr/local/cuda-9.0/lib64.bashrc下行添加到您的.bashrc文件(或您使用的任何其他终端)中

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64/
收藏
评论

试试下面的代码

 pip3 install --upgrade tensorflow-gpu==1.4

在终端中键入此命令pip3 install --upgrade tensorflow-gpu==1.4后,tensorflow将降级为1.4.0。这个错误是由tensorflow 1.6.0引起的。

收藏
评论
新手导航
  • 社区规范
  • 提出问题
  • 进行投票
  • 个人资料
  • 优化问题
  • 回答问题