我在运行Ubuntu 16.04的系统上安装了tensorflow-gpu
。 import tensorflow
工作正常,在终端上的python CLI和IPython上加载CUDA。但在导入IPython QtConsole
时,出现以下错误。在Python CLI和IPython CLI中导入TensorFlow但不在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笔记本tensorflow工程,以及,但不是在IPython的QtConsole
- 我试图运行作为
jupyter qtconsole
代替ipython qtconsole
,相同的错误消息
我已经删除了内核,可否详细说明'PBR'部分? 我不知道那是什么或如何找到pbr版本('pbr。__version__')给我一个错误 –
你可以从你的venv运行'pip list'来检查哪个版本的pbr正在运行。然后,您可以通过执行[this]这一行来将export语句添加到您的bash配置文件中(https://stackoverflow.com/questions/14524590/how-to-add-export-statement-in-a-bash-轮廓文件?RQ = 1)。 我不得不将'export PBR_VERSION = 3.1.1'添加到我的bashrc中以使其工作。希望这有助于你! – naki
它的工作原理!非常感谢 :) –