如何在Spyder IDE(没有anaconda)中导入GPU张量流?

时间:2016-11-21 06:34:24

标签: python tensorflow spyder

我最近成功地在我的Ubuntu 16.04上安装了支持GPU的tensorflow,并且我能够在终端中成功运行一些测试。后来我决定用一个IDE来编写python代码会更容易,我只需要将numpy和tensorflow导入IDE并在那里运行所有内容。成功安装Tensorflow之后,我不想创建另一个Anaconda版本的所有内容,所以我只是直接从Ubuntu软件安装了Spyder2。但是,当我尝试在Spyder2中导入tensorflow时

import tensorflow as tf

它失败并显示以下消息:

ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python      
/__init__.py", line 49, 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


Error importing tensorflow.  Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python    
interpreter from there.

我可以导入numpy没有问题,但没有tensorflow。我是Linux的新手;我在这里失踪的是什么?或者我需要anaconda才能使用Spyder和Tensorflow?谢谢!

1 个答案:

答案 0 :(得分:1)

必须设置这些环境变量,让TensorFlow知道在哪里找到Cuda:

LD_LIBRARY_PATH=/usr/local/cuda/lib64
CUDA_PATH=/usr/local/cuda