TensorFlow:libcudart.so.7.5:无法打开共享对象文件:没有这样的文件或目录

时间:2016-03-22 15:54:19

标签: python ubuntu cuda tensorflow

我在Ubuntu 15.10上运行TensorFlow。当我输入pip show tensorflow时,我看到TF已正确安装。

但是,当我写import tensorflow as tf时,我收到以下错误消息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow import contrib
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/__init__.py", line 23, in <module>
    from tensorflow.contrib import layers
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/layers/__init__.py", line 68, in <module>
    from tensorflow.contrib.layers.python.layers import *
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/__init__.py", line 22, in <module>
    from tensorflow.contrib.layers.python.layers.initializers import *
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/initializers.py", line 24, in <module>
    from tensorflow.python.ops import random_ops
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/random_ops.py", line 23, in <module>
    from tensorflow.python.framework import ops
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 39, in <module>
    from tensorflow.python.framework import versions
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/versions.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/me/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory

对于它的价值,我已按照说明here设置了我的LD_LIBRARY_PATHCUDA_HOME环境变量。

有什么建议吗?

修改

我已经安装了CUDA 7.5并将其添加到我的.profile文件中:

export LD_LIBRARY_PATH="/usr/local/cuda-7.5/lib64"
export CUDA_HOME=/usr/local/cuda-7.5

但是,我仍然看到相同的错误消息。

修改

运行ldd /usr/local/cuda-7.5/lib64/libcudart.so.7.5时,我看到以下输出:

linux-vdso.so.1 =>  (0x00007ffdac7ea000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc27a281000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc27a07d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc279e5e000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fc279c56000)
/lib64/ld-linux-x86-64.so.2 (0x00005604f5406000)

修改

如果相关,我使用的是GeForce GT640。

修改

我跟着@tommus' advice并在运行TensorFlow之前调用source ~/.profile,现在它就像魅力一样。

感谢所有试图在评论中帮助我的人 - 这是我在任何类型的Linux发行版中的第一次体验,而且我非常感谢非常感谢我收到的所有患者帮助远:-)你们真是棒极了!

5 个答案:

答案 0 :(得分:8)

编辑.profile文件后,您需要注销并重新登录或运行以下命令:

source ~/.profile

解决方案是持久的,所以不需要再次执行它。

答案 1 :(得分:4)

sudo nano /etc/ld.so.conf.d/nvidia.conf

添加:

/usr/local/cuda-8.0/lib64

/usr/local/cuda-8.0/lib

运行

sudo ldconfig

如果效果很好,请告诉我。

答案 2 :(得分:3)

如果您使用pip但其他答案对您不起作用,请尝试此操作。

在我的情况下,这个确切的问题是通过重新安装张量流解决的:

timeout

在安装Tensorflow之后安装其他软件包时,Pip必须搞砸了它的依赖关系(之后我为了我自己的目的运行了pip install tensorflow - &gt;这打破了Tensorflow)。

答案 3 :(得分:0)

您可能需要更新cuDNN版本,因为Tensorflow 1.3不适用于cuDNN 5.1或更早版本。下载cuDNN 6.0或更高版本并安装以解决问题

答案 4 :(得分:0)

我有同样的错误。我必须有Cuda 8.0CuDNN 5.1才能进行一些实验!

解决方案:使用Sudo Python

运行python
python
Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import tensorflow
Traceback (most recent call last):
File "", line 1, in 
File "/home/ujjval/anaconda2/lib/python2.7/site-packages/tensorflow/init.py", line 22, in 
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/ujjval/anaconda2/lib/python2.7/site-packages/tensorflow/python/init.py", line 49, in 
from tensorflow.python import pywrap_tensorflow
File "/home/ujjval/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in 
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/ujjval/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in 
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/ujjval/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in 
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/ujjval/anaconda2/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

无法加载本地TensorFlow运行时。