gpt4 book ai didi

python - 带 CUDA 的 tensorflow : ImportError

转载 作者:太空宇宙 更新时间:2023-11-03 14:56:57 25 4
gpt4 key购买 nike

我已经按照 NVIDIA 教程(Ubuntu 16.04 桌面,GTX 970)中的说明逐步安装了 TensorFlow:

http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html

每个步骤都没有错误地完成,但如果我之后尝试在 Python 中导入 TensorFlow,我总是会收到此错误消息:

>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

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

我已将 CUDA 工具包安装到/opt/cuda/toolkit(也称为 cuDNN)。我已经尝试过符号链接(symbolic link):

sudo ln -s /opt/cuda-toolkit /usr/local/cuda
sudo ln -s /opt/cuda-toolkit /usr/local/cuda-8.0

或者这个:

sudo export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cuda-toolkit/lib64:/opt/cuda-toolkit/extras/CUPTI/lib64
sudo export CUDA_HOME=/opt/cuda-toolkit

但是错误依旧。谁能告诉我为什么会出现此错误?非常感谢:)

最佳答案

我在具有类似硬件 (GTX 970M) 的机器上遇到了类似的问题,我使用以下帖子中提供的步骤解决了它: https://askubuntu.com/a/278840

我的情况唯一不同的是,在 nvidia.conf 文件中,我只添加了以下行:/usr/local/cuda-8.0/lib64

然后运行:sudo ldconfig

希望对您有所帮助:)

关于python - 带 CUDA 的 tensorflow : ImportError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41746576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com