简体   繁体   English

使用CUDA的Tensorflow:ImportError

[英]Tensorflow with CUDA: ImportError

I've installed TensorFlow step by step like described in this tutorial from NVIDIA (Ubuntu 16.04 Desktop, GTX 970): 我已经像NVIDIA(Ubuntu 16.04 Desktop,GTX 970)本教程中所描述的那样逐步安装了TensorFlow:

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

Every steps completes without errors, but if I try to import TensorFlow in Python afterwards I'm always gettin' this error message: 每个步骤都完成没有错误,但如果我尝试在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.

I've installed the CUDA-Toolkit to /opt/cuda/toolkit (also cuDNN). 我已经将CUDA-Toolkit安装到/ opt / cuda / toolkit(也是cuDNN)。 I already tried to symlink: 我已经尝试过符号链接:

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

Or this: 或这个:

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

But the error remains. 但错误仍然存​​在。 Can anybody give me a hint why this error occurs? 任何人都可以给我一个暗示,为什么会出现这个错误? Thanks a lot :) 非常感谢 :)

I had a similar problem on a machine with similar hardware (GTX 970M) and I solved it using the steps provided in the following post: https://askubuntu.com/a/278840 我在具有类似硬件的机器(GTX 970M)上遇到了类似的问题,我使用以下帖子中提供的步骤解决了这个问题: https ://askubuntu.com/a/278840

The only difference in my case was that in the nvidia.conf file I added only the following line: /usr/local/cuda-8.0/lib64 我的唯一区别是在nvidia.conf文件中我只添加了以下行:/usr/local/cuda-8.0/lib64

and then ran: sudo ldconfig 然后运行:sudo ldconfig

Hope it helps :) 希望能帮助到你 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM