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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36159194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 17:29:50  来源:igfitidea点击:

TensorFlow: libcudart.so.7.5: cannot open shared object file: No such file or directory

pythonubuntucudatensorflow

提问by MY_G

I am running TensorFlow on Ubuntu 15.10. When I enter pip show tensorflow, I see that TF has been installed properly.

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

However, when I write import tensorflow as tf, I get the following error message:

但是,当我写入时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

For what it's worth, I have followed the instructions hereand set my LD_LIBRARY_PATHand CUDA_HOMEenvironment variables.

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

Any advice?

有什么建议吗?

EDIT:

编辑:

I have installed CUDA 7.5 and added these to my .profilefile:

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

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

However, I continue to see the same error message.

但是,我继续看到相同的错误消息。

EDIT:

编辑:

I see the following output when I run ldd /usr/local/cuda-7.5/lib64/libcudart.so.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)

EDIT:

编辑:

If it is relevant, I use GeForce GT640.

如果相关,我使用 GeForce GT640。

EDIT:

编辑:

I followed @tommus' adviceand called source ~/.profilebefore running TensorFlow, and now it works like a charm.

我遵循了@tommus 的建议source ~/.profile在运行 TensorFlow 之前调用了它,现在它就像一个魅力。

Thanks to everyone who tried to help me in the comments -- this is my first experience with any kind of Linux distribution, and I am really very appreciativeof all the patient assistance I have received so far :-) You guys are absolutely awesome!

感谢所有试图在评论中帮助我的人——这是我第一次体验任何类型的 Linux 发行版,我真的非常感谢迄今为止我收到的所有耐心帮助 :-) 你们真是太棒了!

采纳答案by Tomasz Dzieniak

After editing .profilefile you either need to log out and log back in or run the following command:

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

source ~/.profile

source ~/.profile

The solution is persistent so there is no need to perform it ever again.

该解决方案是持久的,因此无需再次执行。

回答by dreamer

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

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

Add this:

添加这个:

/usr/local/cuda-8.0/lib64

/usr/local/cuda-8.0/lib64

/usr/local/cuda-8.0/lib

/usr/local/cuda-8.0/lib

run

sudo ldconfig

sudo ldconfig

if it works well ,please tell me.

如果它运作良好,请告诉我。

回答by Evusas

If you are using pip but other answers did not work for you, try this.

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

In my case this exact problem was solved by reinstalling tensorflowusing:

在我的情况下,这个确切的问题是通过使用以下方法重新安装 tensorflow解决的:

pip install tensorflow

Pip must have messed up its dependencies or something when installing other packages after Tensorflow installation (I've run pip install -r requirements.txtafterwards for my own purposes --> that broke Tensorflow).

在 Tensorflow 安装之后安装其他软件包时,Pip 一定搞砸了它的依赖项或其他东西(我pip install -r requirements.txt后来出于自己的目的运行了 --> 这破坏了 Tensorflow)。

回答by Ujjval Rathod

I had same error. I have to have Cuda 8.0and CuDNN 5.1for running some experiments!!

我有同样的错误。我必须有Cuda 8.0并且CuDNN 5.1为了运行一些实验!!

SOLUTION: Run python with Sudo Python

解决方案:运行 python Sudo 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

Failed to load the native TensorFlowruntime.

无法加载本机TensorFlow运行时。

回答by Asad

You maybe need to update your cuDNN version as Tensorflow 1.3 doesn't work with cuDNN 5.1 or earlier. Download cuDNN 6.0 or upper and install to fix the issue

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