python - 出现 ImportError:libcublas.so.9.0:无法打开共享对象文件:没有这样的文件或目录 - 降级 TF 版本不起作用
问题描述
我知道这个问题之前可能已经被问过,但我还没有找到适合我的情况的解决方案。
我正在尝试安装tensorflow-gpu
,但它不断返回错误:
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/
我不太确定如何解决这个问题。让 pytorch 与 GPU 一起工作我绝对没有问题,但是对于 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
. 我不太确定如何解决这个问题。
解决方案
工作解决方案:
进行全新安装并按照本教程中的步骤成功解决了 Ubuntu 16.04 的问题。本质上,在安装 cuda、cudnn 和 tensorflow 时,请注意哪些版本是兼容的。例如,tensorflow-gpu-12.0 需要 cuda-9.0。
推荐阅读
- python - keras ANN 中的输入和输出形状
- javascript - 在 NuxtJS 中的布局之间共享一个页眉/页脚
- c# - 尝试使用 selenium 和 .NET 按 ID 选择元素,但由于使用 Shadowroot 元素而出现异常 NoSuchElement
- go - 切换到新G时,P会将mcache复制到G堆栈吗?
- ms-access - 为什么 Microsoft.Jet.OLEDB.4.0 在我的计算机上抱怨 Undefined Functions 而在其他计算机上却没有?
- java - 当我尝试在 NetBeans 12 中运行 FormsFX 演示时,如何修复“缺少 JavaFX 运行时组件”Maven 错误?
- java - 使用 Spring Boot 2.2+,当应用程序不在云平台上运行时,如何创建 bean
- c# - NullReferenceException:对象引用未设置为 Unity Wave Function Collapse 中的对象实例
- cassandra - “spring data cassandra”是否有客户端负载平衡?
- excel - 如何找到范围内特定单元格的总和?