Tensorflow pip built from source fails on 'import tensorflow'

Question:

Built tensorflow 0.7 from source on Ubuntu 15.10, Cuda 7.5, cudnn 4.0, python 2.7. Bazel build and pip package generation OK. pip install ok. Python script “import tensorflow” fails:

Traceback (most recent call last):
  File "/home/keith/Desktop/tf1.py", line 8, in <module>
    import tensorflow as tf
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 35, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
    from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
    serialized_pb=_b('n,tensorflow/core/framework/tensor_shape.protox12ntensorflow"znx10TensorShapeProtox12-nx03x64imx18x02 x03(x0bx32 .tensorflow.TensorShapeProto.Dimx12x14nx0cunknown_rankx18x03 x01(x08x1a!nx03x44imx12x0cnx04sizex18x01 x01(x03x12x0cnx04namex18x02 x01(tB/nx18org.tensorflow.frameworkBx11TensorShapeProtosPx01x62x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'

Any thoughts?
Thanks

Asked By: Keith Brodie

||

Answers:

This does look like a protobuf library versioning error. There’s a long thread on similar issues here:
https://github.com/tensorflow/tensorflow/issues/11
Towards the end there are some suggested solutions that might help.

Answered By: Pete Warden

I succeed in running TensorFlow 0.7 on a manjaro linux laptop using cuda acceleration by running python with optirun:

$optirun python

However, I had problem with protobuf and I had to uninstall/reinstall previous version of protobuf and tensorflow with pip. See this post

Answered By: Jean-Pat

This is because of protobuf version conflict:
for me i had python-protobuf v2.6.1 installed from apt-get package manager
and while installing tensorflow it installed protobuf v3.3.0 from pip manager

so i uninstalled both:

sudo pip uninstall protobuf
sudo apt-get remove python-protobuf

Reinstalled using pip and it solved the issue!!!

sudo pip install protobuf

Hope this helps..

Answered By: Dwijay Bane
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.