从源安装后 TensorFlow 无法加载运行时

TensorFlow fails to load runtime after installation from source

我在 Ubuntu Linux 16.06 LTS,running the commands from the TensorFlow Linux compilation instructions.

上开始从源代码编译 TensorFlow

我的 CUDA 和 CuDNN 设置有效,因为预编译的 TensorFlow nvidia-docker 图像有效。

在使用 bazel 构建 TensorFlow Python wheel,然后使用 pip 安装 wheel 之后,我在尝试导入 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 wheel 时,会发生此错误。

A similar error happens 当您尝试在安装 Python wheel 之前导入 TensorFlow 时。

此问题的解决方案是将您的工作目录更改为其他目录,同时仍保留在安装 Python 轮的 virtualenv 中。