我在運行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
它的工作原理!非常感謝 :) –