当前位置: 首页>>技术教程>>正文


Tensorflow:ImportError:libcusolver.so.8.0:无法打开共享对象文件:没有这样的文件或目录

python中使用tensorflow的问题描述

在python3中,导入tensorflow时遇到了以下问题:

>>> import tensorflow as tf
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, 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: libcusolver.so.8.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 "<stdin>", 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 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, 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 41, 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: libcusolver.so.8.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.

考虑到版本375有这个BUG:从睡眠模式唤醒电脑后,沿着窗口边界有奇怪的东西,我使用的Nvidia驱动程序是381.09测试版。

而且,我已经安装了CUDA 8.0和cuDNN-v6.0:

rharish@rharish-GL552VW:~$ cd /usr/local
rharish@rharish-GL552VW:/usr/local$ ls
bin         cuda      etc    include  man   share
computecpp  cuda-8.0  games  lib      sbin  src

此外,libcusolver.so.8.0也存在于/usr/local/cuda/lib64/中:

libcusolver.so.8.0 in ‘ls’ output

我已经卸载并重新安装了CUDA,cuDNN,还从源代编译安装过tensorflow。但是,只要将Nvidia驱动程序更新为381.09版本,这个问题就会发生。需要怎么解决这个问题?

最佳解决办法

经验证有效的解决方案:

重新安装nvidia-381,CUDA-8.0(使用runfile)和cuDNN 6.0,然后在.bashrc文件中添加了以下内容:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64/

另外一种解决思路

不需要重新安装上述的各种软件包,只需要安装nvidia-cuda-dev:


sudo apt install nvidia-cuda-dev

然后安装cuDNN(可以从这里下载:https://developer.nvidia.com/cudnn),最后相应地设置LD_LIBRARY_PATH
指向cuda/lib64即可。

延伸阅读:《真正从零开始,TensorFlow详细安装入门图文教程!》,地址:https://www.leiphone.com/news/201606/ORlQ7uK3TIW8xVGF.html

本文整理自

本文由《纯净天空》出品。文章地址: https://vimsky.com/article/3597.html,未经允许,请勿转载。