【发布时间】:2017-11-28 03:00:41
【问题描述】:
我正在尝试加载一个 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.
问题是我在文件夹 /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_LIBRARY_PATH=/usr/local/cuda/lib64/
但是 spyder 中的 python shell 和 ipython shell 似乎都看不到路径?知道我能做什么吗?我在 spyder 中添加了 PYTHONPATH 管理器的路径。我还在我的主文件夹中的 .profile 中添加了数学
【问题讨论】:
-
请从系统终端启动 Spyder 来解决这个问题。我已经在 StackOverflow 上多次回答了这个问题。
-
@CarlosCordoba 你能把这个作为你的答案吗?我会这样标记它。它奏效了。
标签: python tensorflow spyder