ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

一、问题描述

import tensorflow 时遇到错误,报错如下:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/thz/anaconda3/envs/python2/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/home/thz/anaconda3/envs/python2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/thz/anaconda3/envs/python2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/thz/anaconda3/envs/python2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/thz/anaconda3/envs/python2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/thz/anaconda3/envs/python2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
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/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>> 

主要报错是:

ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

二、问题解决

方法一:
tensorflow 与 CUDA 有版本对应关系:
表格来源:https://www.tensorflow.org/install/source#common_installation_problems

tensorflow 版本Python 版本编译器构建工具cuDNNCUDA
tensorflow-2.1.02.7、3.5-3.7GCC 7.3.1Bazel 0.27.17.610.1
tensorflow-2.0.02.7、3.3-3.7GCC 7.3.1Bazel 0.26.17.410.0
tensorflow_gpu-1.14.02.7、3.3-3.7GCC 4.8Bazel 0.24.17.410.0
tensorflow_gpu-1.13.12.7、3.3-3.7GCC 4.8Bazel 0.19.27.410.0
tensorflow_gpu-1.12.02.7、3.3-3.6GCC 4.8Bazel 0.15.079
tensorflow_gpu-1.11.02.7、3.3-3.6GCC 4.8Bazel 0.15.079
tensorflow_gpu-1.10.02.7、3.3-3.6GCC 4.8Bazel 0.15.079
tensorflow_gpu-1.9.02.7、3.3-3.6GCC 4.8Bazel 0.11.079
tensorflow_gpu-1.8.02.7、3.3-3.6GCC 4.8Bazel 0.10.079
tensorflow_gpu-1.7.02.7、3.3-3.6GCC 4.8Bazel 0.9.079
tensorflow_gpu-1.6.02.7、3.3-3.6GCC 4.8Bazel 0.9.079
tensorflow_gpu-1.5.02.7、3.3-3.6GCC 4.8Bazel 0.8.079
tensorflow_gpu-1.4.02.7、3.3-3.6GCC 4.8Bazel 0.5.468
tensorflow_gpu-1.3.02.7、3.3-3.6GCC 4.8Bazel 0.4.568
tensorflow_gpu-1.2.02.7、3.3-3.6GCC 4.8Bazel 0.4.55.18
tensorflow_gpu-1.1.02.7、3.3-3.6GCC 4.8Bazel 0.4.25.18
tensorflow_gpu-1.0.02.7、3.3-3.6GCC 4.8Bazel 0.4.25.18

按照这个对应关系安装就可以了,但不是严格一一对应的,只要版本不相差太远就好,比如我开始的对应是:
CUDA-10.2、tensorflow_gpu-1.4.0
表中的 tensorflow-2.1.0 才支持到 CUDA-10.1,我将 tensorflow_gpu-1.4.0 换成了 tensorflow_gpu-1.14.0,问题解决。

方法二:
比较简单,重装 cudatoolkit,如果是使用 conda 虚拟环境,执行下面的命令:

conda install cudatoolkit=9.0

其中 cudatoolkit 版本号是你的报错中 libcublas.so.9.0 中的版本号。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

万俟淋曦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值