1

I started compiling TensorFlow from source on Ubuntu Linux 16.06 LTS, running the commands from the TensorFlow Linux compilation instructions.

My CUDA and CuDNN setup works, as the pre-compiled TensorFlow nvidia-docker image works.

After using bazel to build the TensorFlow Python wheel, and then installing the wheel with pip, I get the following error message when trying to import 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
James Mishra
  • 4,249
  • 4
  • 30
  • 35

1 Answers1

2

This error happens when you are running Python from the TensorFlow source directory after having installed the Python wheel.

A similar error happens when you try importing TensorFlow before installing the Python wheel.

The solution to this problem is to change your working directory to something else, while still remaining in the virtualenv that you installed the Python wheel to.

James Mishra
  • 4,249
  • 4
  • 30
  • 35