遇到 ImportError: libcublas.so.9.0: 无法打开共享对象文件: 没有那个文件或目录 错误 - 降级TensorFlow版本无效

3
我知道这个问题可能已经被问过了,但我没有找到适用于我的情况的解决方案。
我正在尝试安装tensorflow-gpu,但它一直返回错误:Original Answer
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

过去的回答表明这可能与tensorflow和CUDA的兼容性有关。

当我运行nvcc --version时,我得到:

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

最初的回答:
我已经尝试安装以前版本的tensorflow-gpu,例如tensorflow-gpu==1.12.0、tensorflow-gpu==1.8.0和tensorflow-gpu==1.4.0。但出现的错误是libcublas.so.9.0或libcublas.so.8.0,这取决于tensorflow-gpu的版本。
请注意,我已将LD_LIBRARY_PATH环境变量设置为以下内容:
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/

我不太确定如何解决这个问题。使用GPU让pytorch工作起来非常容易,但是使用tensorflow和keras却会带来很多麻烦。

完整错误信息如下:

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

编辑:我认为我可能已经找到了问题的根本原因在这里。问题在于cuda文件夹的名称为cuda-9.2,而tensorflow正在寻找cuda-9.0。不过我不太确定如何解决这个问题。

最初的回答

1个回答

2

解决方案:

进行全新安装并按照本教程中的步骤操作,可以解决Ubuntu 16.04的问题。在安装cuda、cudnn和tensorflow时,要注意哪些版本是兼容的。例如,tensorflow-gpu-12.0需要cuda-9.0。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接