【发布时间】:2017-03-21 11:15:21
【问题描述】:
我在运行 Ubuntu 16.04 的系统上安装了 tensorflow-gpu。 import tensorflow 运行良好,在 python CLI 上加载 CUDA,在终端上加载 IPython。但是在IPython QtConsole 中导入时,出现以下错误。
ImportErrorTraceback (most recent call last)
<ipython-input-25-41389fad42b5> in <module>()
----> 1 import tensorflow as tf
/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
25 # pylint: enable=wildcard-import
26
/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py in <module>()
70 for some common reasons and solutions. Include the entire stack trace
71 above this error message when asking for help.""" % traceback.format_exc()
---> 72 raise ImportError(msg)
73
74 # Protocol buffers
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.
提到的 URL 是死链接。
我检查了 QtConsole 的环境变量,它没有我在 .bashrc 文件中所做的修改。我使用!export $ENV_VAR=VALUE 更改了变量。后来我尝试了!echo $PATH,但没有反映这些变化。奇怪的O_o
我尝试更改 os.environ 字典。这反映了我的更改,但仍然无法导入 tensorflow
我该如何解决这个问题?
编辑: 1. Jupyter notebook 也可以导入tensorflow,ipython QtConsole不行
- 我尝试以
jupyter qtconsole而不是ipython qtconsole运行,同样的错误消息
【问题讨论】:
标签: python tensorflow ipython