2016-11-21 165 views
2

我最近在我的Ubuntu 16.04上成功安装了支持GPU的tensorflow,我能够在终端上成功运行一些测试。后来我决定用IDE编写Python代码会更容易,我只需将numpy和tensorflow导入到IDE中并在其中运行所有内容。成功安装Tensorflow后,我不想创建另一个Anaconda版本的所有东西,所以我只是直接从Ubuntu软件安装Spyder2。然而,当我尝试的Spyder2如何导入Spyder IDE中的GPU tensorflow(没有anaconda)?

import tensorflow as tf 

进口tensorflow它失败,以下消息:

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

你的CUDA或'LD_LIBRARY_PATH'设置不正确。 – yuefengz

+0

我确定CUDA已经安装,因为我可以在命令行中运行tensorflow。我知道LD_LIBRARY_PATH是一个环境变量 - 你是说环境变量设置不正确的Spyder寻找Tensorflow?如果没有,我应该如何告诉Spyder在哪里寻找Tensorflow? – Rexroth

+0

我想你需要从终端启动Spyder,以便正确地获取你的环境变量(在这个'LD_LIBRARY_PATH'中)。 –

回答

1

这些环境变量必须设置为让TensorFlow知道在哪里找到的Cuda:未安装

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