TeamHG-Memex / tensorboard_logger

Log TensorBoard events without touching TensorFlow
MIT License
630 stars 50 forks source link

TensorFlow import cause an error #11

Closed perone closed 7 years ago

perone commented 7 years ago

If TensorFlow package is imported before or after importing tensorflow_logger, this error is raised:

TypeError: Couldn't build proto file into descriptor pool!

lopuhin commented 7 years ago

Thanks for reporting the bug @perone ! Which TensorFlow version are you using? When does the error happen, when you import TensorFlow or tensorboard_logger? Do you have the full traceback?

perone commented 7 years ago

Hi, sure, I'm using the TensorFlow 1.1.0 and installed tensorboard_logger using pip. I'm on Ubuntu. To reproduce it is very simple:

In [1]: import tensorflow as tf

In [2]: tf.__version__
Out[2]: '1.1.0'

In [3]: import tensorboard_logger as tblogger
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-193949510255> in <module>()
----> 1 import tensorboard_logger as tblogger

/home/chper_local/.virtualenvs/perone/local/lib/python2.7/site-packages/tensorboard_logger/__init__.py in <module>()
      1 # -*- coding: utf-8 -*-
      2 
----> 3 from .tensorboard_logger import *

/home/chper_local/.virtualenvs/perone/local/lib/python2.7/site-packages/tensorboard_logger/tensorboard_logger.py in <module>()
      9 import six
     10 
---> 11 from .tf_protobuf import summary_pb2, event_pb2
     12 from .crc32c import crc32c
     13 

/home/chper_local/.virtualenvs/perone/local/lib/python2.7/site-packages/tensorboard_logger/tf_protobuf/summary_pb2.py in <module>()
     20   package='tensorflow',
     21   syntax='proto3',
---> 22   serialized_pb=_b('\n,tensorboard_logger/tf_protobuf/summary.proto\x12\ntensorflow\"\x87\x01\n\x0eHistogramProto\x12\x0b\n\x03min\x18\x01 \x01(\x01\x12\x0b\n\x03max\x18\x02 \x01(\x01\x12\x0b\n\x03num\x18\x03 \x01(\x01\x12\x0b\n\x03sum\x18\x04 \x01(\x01\x12\x13\n\x0bsum_squares\x18\x05 \x01(\x01\x12\x18\n\x0c\x62ucket_limit\x18\x06 \x03(\x01\x42\x02\x10\x01\x12\x12\n\x06\x62ucket\x18\x07 \x03(\x01\x42\x02\x10\x01\"\x84\x04\n\x07Summary\x12(\n\x05value\x18\x01 \x03(\x0b\x32\x19.tensorflow.Summary.Value\x1aX\n\x05Image\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05width\x18\x02 \x01(\x05\x12\x12\n\ncolorspace\x18\x03 \x01(\x05\x12\x1c\n\x14\x65ncoded_image_string\x18\x04 \x01(\x0c\x1a}\n\x05\x41udio\x12\x13\n\x0bsample_rate\x18\x01 \x01(\x02\x12\x14\n\x0cnum_channels\x18\x02 \x01(\x03\x12\x15\n\rlength_frames\x18\x03 \x01(\x03\x12\x1c\n\x14\x65ncoded_audio_string\x18\x04 \x01(\x0c\x12\x14\n\x0c\x63ontent_type\x18\x05 \x01(\t\x1a\xf5\x01\n\x05Value\x12\x11\n\tnode_name\x18\x07 \x01(\t\x12\x0b\n\x03tag\x18\x01 \x01(\t\x12\x16\n\x0csimple_value\x18\x02 \x01(\x02H\x00\x12&\n\x1cobsolete_old_style_histogram\x18\x03 \x01(\x0cH\x00\x12*\n\x05image\x18\x04 \x01(\x0b\x32\x19.tensorflow.Summary.ImageH\x00\x12+\n\x05histo\x18\x05 \x01(\x0b\x32\x1a.tensorflow.HistogramProtoH\x00\x12*\n\x05\x61udio\x18\x06 \x01(\x0b\x32\x19.tensorflow.Summary.AudioH\x00\x42\x07\n\x05valueB\x03\xf8\x01\x01\x62\x06proto3')
     23 )
     24 _sym_db.RegisterFileDescriptor(DESCRIPTOR)

/home/chper_local/.virtualenvs/perone/local/lib/python2.7/site-packages/google/protobuf/descriptor.pyc in __new__(cls, name, package, options, serialized_pb, dependencies, public_dependencies, syntax, pool)
    822         # TODO(amauryfa): use the pool passed as argument. This will work only
    823         # for C++-implemented DescriptorPools.
--> 824         return _message.default_pool.AddSerializedFile(serialized_pb)
    825       else:
    826         return super(FileDescriptor, cls).__new__(cls)

TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "tensorboard_logger/tf_protobuf/summary.proto":
  tensorflow.HistogramProto.min: "tensorflow.HistogramProto.min" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.max: "tensorflow.HistogramProto.max" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.num: "tensorflow.HistogramProto.num" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.sum: "tensorflow.HistogramProto.sum" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.sum_squares: "tensorflow.HistogramProto.sum_squares" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.bucket_limit: "tensorflow.HistogramProto.bucket_limit" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.bucket: "tensorflow.HistogramProto.bucket" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto: "tensorflow.HistogramProto" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.value: "tensorflow.Summary.value" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image.height: "tensorflow.Summary.Image.height" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image.width: "tensorflow.Summary.Image.width" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image.colorspace: "tensorflow.Summary.Image.colorspace" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image.encoded_image_string: "tensorflow.Summary.Image.encoded_image_string" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image: "tensorflow.Summary.Image" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.sample_rate: "tensorflow.Summary.Audio.sample_rate" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.num_channels: "tensorflow.Summary.Audio.num_channels" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.length_frames: "tensorflow.Summary.Audio.length_frames" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.encoded_audio_string: "tensorflow.Summary.Audio.encoded_audio_string" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.content_type: "tensorflow.Summary.Audio.content_type" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio: "tensorflow.Summary.Audio" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.value: "tensorflow.Summary.Value.value" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.node_name: "tensorflow.Summary.Value.node_name" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.tag: "tensorflow.Summary.Value.tag" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.simple_value: "tensorflow.Summary.Value.simple_value" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.obsolete_old_style_histogram: "tensorflow.Summary.Value.obsolete_old_style_histogram" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.image: "tensorflow.Summary.Value.image" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.histo: "tensorflow.Summary.Value.histo" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.audio: "tensorflow.Summary.Value.audio" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value: "tensorflow.Summary.Value" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary: "tensorflow.Summary" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.image: "tensorflow.Summary.Image" seems to be defined in "tensorflow/core/framework/summary.proto", which is not imported by "tensorboard_logger/tf_protobuf/summary.proto".  To use it here, please add the necessary import.
  tensorflow.Summary.Value.histo: "tensorflow.HistogramProto" seems to be defined in "tensorflow/core/framework/summary.proto", which is not imported by "tensorboard_logger/tf_protobuf/summary.proto".  To use it here, please add the necessary import.
  tensorflow.Summary.Value.audio: "tensorflow.Summary.Audio" seems to be defined in "tensorflow/core/framework/summary.proto", which is not imported by "tensorboard_logger/tf_protobuf/summary.proto".  To use it here, please add the necessary import.
  tensorflow.Summary.value: "tensorflow.Summary.Value" seems to be defined in "tensorflow/core/framework/summary.proto", which is not imported by "tensorboard_logger/tf_protobuf/summary.proto".  To use it here, please add the necessary import.
lopuhin commented 7 years ago

Aha, I see, thanks! That's definitely worth fixing.

Btw, what is your use-case for tensorboard_logger? The idea behind it is to be able to log values in tensorboard format without using tensorflow (e.g. from a different framework or if you don't want tensorflow dependency). In which case do you want to import both?

perone commented 7 years ago

It really seems a strange case, why would I use tensorboard_logger if I'm using TensorFlow ? However my problem lies on dependencies. I have an external requirement that for some reason imports TensorFlow and causes this problem.

lopuhin commented 7 years ago

That makes sense, thanks!

lopuhin commented 7 years ago

Unfortunately I wasn't able to reproduce the bug, it might depend on some other environment differences, but I see how it could happen. So I tried to make a fix in the run-with-tf branch (see linked commit above) - any chance you could try it out and see if this fixes the bug for you?

perone commented 7 years ago

I tested with the run-with-tf branch and it is working fine now, thanks a lot and congrats for the project.

sidwa commented 5 years ago

I'm getting more or less the same error without importing tensorflow anywhere.

Traceback (most recent call last):
  File "train.py", line 16, in <module>
    import tensorboard_logger as tb_logger
  File "/home/sxr8618/.local/lib/python2.7/site-packages/tensorboard_logger/__init__.py", line 3, in <module>
    from .tensorboard_logger import *
  File "/home/sxr8618/.local/lib/python2.7/site-packages/tensorboard_logger/tensorboard_logger.py", line 22, in <module>
    from .tf_protobuf import summary_pb2, event_pb2
  File "/home/sxr8618/.local/lib/python2.7/site-packages/tensorboard_logger/tf_protobuf/summary_pb2.py", line 22, in <module>
    serialized_pb=_b('\n,tensorboard_logger/tf_protobuf/summary.proto\x12\ntensorflow\"\x87\x01\n\x0eHistogramProto\x12\x0b\n\x03min\x18\x01 \x01(\x01\x12\x0b\n\x03max\x18\x02 \x01(\x01\x12\x0b\n\x03num\x18\x03 \x01(\x01\x12\x0b\n\x03sum\x18\x04 \x01(\x01\x12\x13\n\x0bsum_squares\x18\x05 \x01(\x01\x12\x18\n\x0c\x62ucket_limit\x18\x06 \x03(\x01\x42\x02\x10\x01\x12\x12\n\x06\x62ucket\x18\x07 \x03(\x01\x42\x02\x10\x01\"\x84\x04\n\x07Summary\x12(\n\x05value\x18\x01 \x03(\x0b\x32\x19.tensorflow.Summary.Value\x1aX\n\x05Image\x12\x0e\n\x06height\x18\x01 \x01(\x05\x12\r\n\x05width\x18\x02 \x01(\x05\x12\x12\n\ncolorspace\x18\x03 \x01(\x05\x12\x1c\n\x14\x65ncoded_image_string\x18\x04 \x01(\x0c\x1a}\n\x05\x41udio\x12\x13\n\x0bsample_rate\x18\x01 \x01(\x02\x12\x14\n\x0cnum_channels\x18\x02 \x01(\x03\x12\x15\n\rlength_frames\x18\x03 \x01(\x03\x12\x1c\n\x14\x65ncoded_audio_string\x18\x04 \x01(\x0c\x12\x14\n\x0c\x63ontent_type\x18\x05 \x01(\t\x1a\xf5\x01\n\x05Value\x12\x11\n\tnode_name\x18\x07 \x01(\t\x12\x0b\n\x03tag\x18\x01 \x01(\t\x12\x16\n\x0csimple_value\x18\x02 \x01(\x02H\x00\x12&\n\x1cobsolete_old_style_histogram\x18\x03 \x01(\x0cH\x00\x12*\n\x05image\x18\x04 \x01(\x0b\x32\x19.tensorflow.Summary.ImageH\x00\x12+\n\x05histo\x18\x05 \x01(\x0b\x32\x1a.tensorflow.HistogramProtoH\x00\x12*\n\x05\x61udio\x18\x06 \x01(\x0b\x32\x19.tensorflow.Summary.AudioH\x00\x42\x07\n\x05valueB\x03\xf8\x01\x01\x62\x06proto3')
  File "/usr/local/lib/python2.7/dist-packages/google/protobuf/descriptor.py", line 878, in __new__
    return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "tensorboard_logger/tf_protobuf/summary.proto":
  tensorflow.HistogramProto.min: "tensorflow.HistogramProto.min" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.max: "tensorflow.HistogramProto.max" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.num: "tensorflow.HistogramProto.num" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.sum: "tensorflow.HistogramProto.sum" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.sum_squares: "tensorflow.HistogramProto.sum_squares" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.bucket_limit: "tensorflow.HistogramProto.bucket_limit" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto.bucket: "tensorflow.HistogramProto.bucket" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.HistogramProto: "tensorflow.HistogramProto" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.value: "tensorflow.Summary.value" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image.height: "tensorflow.Summary.Image.height" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image.width: "tensorflow.Summary.Image.width" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image.colorspace: "tensorflow.Summary.Image.colorspace" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image.encoded_image_string: "tensorflow.Summary.Image.encoded_image_string" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Image: "tensorflow.Summary.Image" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.sample_rate: "tensorflow.Summary.Audio.sample_rate" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.num_channels: "tensorflow.Summary.Audio.num_channels" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.length_frames: "tensorflow.Summary.Audio.length_frames" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.encoded_audio_string: "tensorflow.Summary.Audio.encoded_audio_string" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio.content_type: "tensorflow.Summary.Audio.content_type" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Audio: "tensorflow.Summary.Audio" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.value: "tensorflow.Summary.Value.value" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.node_name: "tensorflow.Summary.Value.node_name" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.tag: "tensorflow.Summary.Value.tag" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.simple_value: "tensorflow.Summary.Value.simple_value" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.obsolete_old_style_histogram: "tensorflow.Summary.Value.obsolete_old_style_histogram" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.image: "tensorflow.Summary.Value.image" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.histo: "tensorflow.Summary.Value.histo" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.audio: "tensorflow.Summary.Value.audio" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value: "tensorflow.Summary.Value" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary: "tensorflow.Summary" is already defined in file "tensorflow/core/framework/summary.proto".
  tensorflow.Summary.Value.image: "tensorflow.Summary.Image" seems to be defined in "tensorflow/core/framework/summary.proto", which is not imported by "tensorboard_logger/tf_protobuf/summary.proto".  To use it here, please add the necessary import.
  tensorflow.Summary.Value.histo: "tensorflow.HistogramProto" seems to be defined in "tensorflow/core/framework/summary.proto", which is not imported by "tensorboard_logger/tf_protobuf/summary.proto".  To use it here, please add the necessary import.
  tensorflow.Summary.Value.audio: "tensorflow.Summary.Audio" seems to be defined in "tensorflow/core/framework/summary.proto", which is not imported by "tensorboard_logger/tf_protobuf/summary.proto".  To use it here, please add the necessary import.
  tensorflow.Summary.value: "tensorflow.Summary.Value" seems to be defined in "tensorflow/core/framework/summary.proto", which is not imported by "tensorboard_logger/tf_protobuf/summary.proto".  To use it here, please add the necessary import.