pythonmacostensorflowbuild

tensorflow cannot import name container_types


I've just compiled tensorflow from source code with GPU support on OSX. This was with a few hick-ups and hacks along the way:

Finally I've compiled the .whl file and installed in a virtual environment, however, when I try to import tensorflow, I get these errors:

import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Volumes/GP_2T/tensorflow_tutorials/tf_src/venv/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/Volumes/GP_2T/tensorflow_tutorials/tf_src/venv/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 63, in <module>
    from tensorflow.python.framework.framework_lib import *
  File "/Volumes/GP_2T/tensorflow_tutorials/tf_src/venv/lib/python2.7/site-packages/tensorflow/python/framework/framework_lib.py", line 102, in <module>
    from tensorflow.python.framework.importer import import_graph_def
  File "/Volumes/GP_2T/tensorflow_tutorials/tf_src/venv/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 30, in <module>
    from tensorflow.python.framework import function
  File "/Volumes/GP_2T/tensorflow_tutorials/tf_src/venv/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 33, in <module>
    from tensorflow.python.ops import resource_variable_ops
  File "/Volumes/GP_2T/tensorflow_tutorials/tf_src/venv/lib/python2.7/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 25, in <module>
    from tensorflow.python.eager import custom_gradient
  File "/Volumes/GP_2T/tensorflow_tutorials/tf_src/venv/lib/python2.7/site-packages/tensorflow/python/eager/custom_gradient.py", line 23, in <module>
    from tensorflow.python.eager import tape
  File "/Volumes/GP_2T/tensorflow_tutorials/tf_src/venv/lib/python2.7/site-packages/tensorflow/python/eager/tape.py", line 23, in <module>
    from autograd import container_types
ImportError: cannot import name container_types

My setup is OSX 10.11.5 with bazel 0.5.4, CUDA 8.0, cudnn 5.1 and XCode 7.0

Has anyone else bumped into this issue ? Any clues on how I could get myself unstuck / what should I double check ?


Solution

  • Eventually solved the issue by pulling the latest version from the repo (currently 1.6.0-rc0) and using a few super helpful github comments on Eigen and Protobuf errors.

    More details in this answer

    I've uploaded a TensorFlow 1.6.0 OSX GPU .whl on github.