我开始在 Ubuntu Linux 16.06 LTS 上从源代码编译 TensorFlow,running the commands from the TensorFlow Linux compilation instructions .
我的 CUDA 和 CuDNN 设置可以正常工作,就像预编译的 TensorFlow nvidia-docker 镜像可以正常工作一样。
使用 bazel 构建 TensorFlow Python 轮子,然后使用 pip 安装轮子后,在尝试导入 TensorFlow 时收到以下错误消息:
>>> import tensorflow
Traceback (most recent call last):
File "/home/james/workspace/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/james/workspace/tensorflow/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/james/workspace/tensorflow/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/james/workspace/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/james/workspace/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
最佳答案
当您安装 Python 轮后从 TensorFlow 源目录运行 Python 时,会发生此错误。
一个similar error happens当您在安装 Python 轮之前尝试导入 TensorFlow 时。
此问题的解决方案是将工作目录更改为其他目录,同时仍保留在安装 Python 轮子的 virtualenv 中。
关于python - 从源安装后,TensorFlow 无法加载运行时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45702962/