Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Spyder-导入tensorflow会产生错误_Python_Tensorflow_Spyder - Fatal编程技术网

Python Spyder-导入tensorflow会产生错误

Python Spyder-导入tensorflow会产生错误,python,tensorflow,spyder,Python,Tensorflow,Spyder,我正在尝试加载tensorflow项目。它将使用GPU 每次导入tensorflow时都会出现错误: sys.path Out[5]: ['', '/usr/local/lib/python2.7/dist-packages/spyder/utils/site', '/usr/local/cuda/lib64', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/

我正在尝试加载tensorflow项目。它将使用GPU

每次导入tensorflow时都会出现错误:

sys.path
Out[5]: 
['',
 '/usr/local/lib/python2.7/dist-packages/spyder/utils/site',
 '/usr/local/cuda/lib64',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/local/lib/python2.7/dist-packages/IPython/extensions',
 '/home/kevin/.ipython']

import tensorflow
Traceback (most recent call last):

  File "<ipython-input-6-a649b509054f>", line 1, in <module>
    import tensorflow

  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 49, in <module>
    from tensorflow.python import pywrap_tensorflow

  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)

ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
sys.path
出[5]:
['',
“/usr/local/lib/python2.7/dist-packages/spyder/utils/site”,
“/usr/local/cuda/lib64”,
“/usr/lib/python2.7”,
“/usr/lib/python2.7/plat-x86_64-linux-gnu”,
“/usr/lib/python2.7/lib-tk”,
“/usr/lib/python2.7/lib old”,
“/usr/lib/python2.7/lib dynload”,
“/usr/local/lib/python2.7/dist包”,
“/usr/lib/python2.7/dist包”,
“/usr/local/lib/python2.7/dist-packages/IPython/extensions”,
“/home/kevin/.ipython”]
输入张量流
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
输入张量流
文件“/usr/local/lib/python2.7/dist-packages/tensorflow/_-init__.py”,第24行,在
从tensorflow.python导入*
文件“/usr/local/lib/python2.7/dist packages/tensorflow/python/_init__.py”,第49行,在
从tensorflow.python导入pywrap\u tensorflow
文件“/usr/local/lib/python2.7/dist packages/tensorflow/python/pywrap_tensorflow.py”,第52行,在
提高效率(msg)
ImportError:回溯(最近一次呼叫上次):
文件“/usr/local/lib/python2.7/dist packages/tensorflow/python/pywrap_tensorflow.py”,第41行,在
从tensorflow.python.pywrap\u tensorflow\u内部导入*
文件“/usr/local/lib/python2.7/dist packages/tensorflow/python/pywrap\u tensorflow\u internal.py”,第28行,在
_pywrap\u tensorflow\u internal=swig\u import\u helper()
swig\u import\u helper中的文件“/usr/local/lib/python2.7/dist packages/tensorflow/python/pywrap\u tensorflow\u internal.py”,第24行
_mod=imp.load_模块(“pywrap_tensorflow_internal”,fp,路径名,描述)
ImportError:libcudnn.so.5:无法打开共享对象文件:没有此类文件或目录
未能加载本机TensorFlow运行时。
看见https://www.tensorflow.org/install/install_sources#common_installation_problems
因为一些常见的原因和解决方案。包括整个堆栈跟踪
以上是请求帮助时的错误消息。
问题是我确实在文件夹
/usr/local/cuda/lib64
中有文件(
libcudnn.so.5

ls/usr/local/cuda/lib64/ lib64/libcudnn.so.5@libcudnn.so.6.0.21* libcudnn.so@libcudnn.so.6@libcudnn_static.a

令我沮丧的是,我实际上可以直接从终端中的ipython和终端中的常规python shell加载tensorflow。我在我的.bashrc:
export-LD\u-LIBRARY\u-PATH=/usr/local/cuda/lib64中有这个/

但是spyder中的python外壳和ipython外壳似乎都没有看到路径?你知道我能做什么吗?我在spyder中添加了PYTHONPATH管理器的路径。我还将数学添加到了我的主文件夹中的.profile中(此处为Spyder developer),您需要从系统终端启动Spyder来解决此问题

这是因为从Unity启动Spyder时,它不会获取终端中定义的环境变量。

(此处为Spyder developer)您需要从系统终端启动Spyder来解决此问题


这是因为从Unity启动Spyder时,它不会获取终端中定义的环境变量。

请从系统终端启动Spyder以解决此问题。我在StackOverflow已经回答过这个问题好几次了。@CarlosCordoba你能把这个作为你的答案吗。我会这样做的。成功了。请从系统终端启动Spyder以解决此问题。我在StackOverflow已经回答过这个问题好几次了。@CarlosCordoba你能把这个作为你的答案吗。我会这样做的。成功了。