tensorboard icon indicating copy to clipboard operation
tensorboard copied to clipboard

What could be possible reasons for "TypeError: Value must be iterable"?

Open soloice opened this issue 9 years ago • 7 comments

I'm using TensorFlow on Ubuntu 16.04 with GTX 1080 Ti cards, CUDA 8 and cuDNN 7. Since TF binary do not include cuDNN 7 currently (it uses cuDNN 6 instead), I built TF from sources with Bazel. Training models is fine with my settings, but Tensorboard doesn't work.

This is my error info:

tensorboard --logdir=/tmp/tensorflow_logs
TensorBoard 0.1.8 at http://user-ubuntu:6006 (Press CTRL+C to quit)
Exception in thread Reloader:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tensorboard/backend/application.py", line 327, in _reload_forever
    reload_multiplexer(multiplexer, path_to_run)
  File "/usr/local/lib/python2.7/dist-packages/tensorboard/backend/application.py", line 301, in reload_multiplexer
    multiplexer.Reload()
  File "/usr/local/lib/python2.7/dist-packages/tensorboard/backend/event_processing/plugin_event_multiplexer.py", line 195, in Reload
    accumulator.Reload()
  File "/usr/local/lib/python2.7/dist-packages/tensorboard/backend/event_processing/plugin_event_accumulator.py", line 189, in Reload
    self._ProcessEvent(event)
  File "/usr/local/lib/python2.7/dist-packages/tensorboard/backend/event_processing/plugin_event_accumulator.py", line 335, in _ProcessEvent
    value = data_compat.migrate_value(value)
  File "/usr/local/lib/python2.7/dist-packages/tensorboard/data_compat.py", line 57, in migrate_value
    return handler(value) if handler else value
  File "/usr/local/lib/python2.7/dist-packages/tensorboard/data_compat.py", line 109, in _migrate_scalar_value
    description=value.metadata.summary_description)
  File "/usr/local/lib/python2.7/dist-packages/tensorboard/plugins/scalar/metadata.py", line 45, in create_summary_metadata
    content=content.SerializeToString()))
TypeError: Value must be iterable

I thought it might have something to do with protobuf, so I upgraded protobuf to version 3.4.0, but the same error occurs again. Do you have any idea with this? What might be wrong? Any suggestion would be helpful. Thanks!

soloice avatar Oct 10 '17 06:10 soloice

This is pretty surprising. That error comes from the protobuf extension module, and is raised when passing a scalar field to a repeated field: e.g., if you had

message Example {
  repeated int32 xs = 1;
}

but tried to write

import example_pb2
example_pb2.Example(xs=1)  # instead of `xs=[1]`

It's confusing because no field referenced in that statement (link to source) is a repeated field. But in previous versions of TensorFlow tf.SummaryMetadata.plugin_data was a repeated field (we fixed that a while ago).

Is it possible that the TensorFlow sources from which you're building are really out of date, or that your TensorBoard is running against a version of TensorFlow prior to 1.3?

Could you perhaps try the following—edit /usr/local/lib/python2.7/dist-packages/tensorboard/plugins/scalar/metadata.py and at the top of the create_summary_metadata function add the following:

import sys
sys.stderr.write('%r\n' % type(tf.SummaryMetadata().plugin_data))
sys.stderr.write('path to TensorFlow: %s\n' % tf.__file__)
raise AssertionError('XXX temporary debugging code')

and then run TensorBoard again? The first line should print out either <type 'google.protobuf.pyext._message.RepeatedCompositeContainer'> or <class 'tensorflow.core.framework.summary_pb2.PluginData'>. If it's the former, then the problem is what I conjectured, so we just need to link TensorBoard against the right TensorFlow. If it's the latter, then I'm even more confused and we can keep trying to figure this out.

Also, I note that your TensorBoard is not running from within a virtualenv. Is this intentional? (Most people try to run TensorFlow and friends from within a virtualenv, so it's possible that it's picking up a different version than you expect. If you intentionally installed everything system-wide, then this is to be expected.)

wchargin avatar Oct 11 '17 20:10 wchargin

Thanks for your patient and detailed response. It's really helpful!

Is it possible that the TensorFlow sources from which you're building are really out of date, or that your TensorBoard is running against a version of TensorFlow prior to 1.3?

The TensorFlow sources should be a bleeding edge version. I think our system administrator just pulled the code from GitHub 2 or 3 days ago and built it.

I note that your TensorBoard is not running from within a virtualenv. Is this intentional?

Yes, it is. The TensorFlow environment on this machine is unique and system-wide, which is what we expected.

Could you perhaps try the following—edit /usr/local/lib/python2.7/dist-packages/tensorboard/plugins/scalar/metadata.py and at the top of the create_summary_metadata function

Fine. I'll try it and give you more feedback. Thanks for your help!

soloice avatar Oct 12 '17 15:10 soloice

Thanks for your help @wchargin . I'm the administrator @soloice mentioned above. I tried the code and got <type 'google.protobuf.pyext._message.RepeatedCompositeContainer'> in the first line. So I tried to figure out how many tensorflow on the machine and confirmed that there is only one. However there is a strange thing, which is that I compiled tensorflow by myself with bazel and I got tensorflow-1.3.0rc1-cp27-cp27mu-linux_x86_64.whl by bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg, but when I type tf.__version__, I got 1.2.1-rc1 as return value. I wonder why and whether this is the cause of our issue?

FYI, I followed this issue to make tensorflow support for cudnn7.0.

FireBrother avatar Oct 13 '17 16:10 FireBrother

Hi @FireBrother. That's good to hear; this is almost certainly the cause of the issue.

When you say that you followed the instructions in that issue to build TensorFlow, does that include checking out db596594b5653b43fcb558a4753b39904bb62cbd~? That is a relatively old tree, from 2017-08-02, and in particular it is six days before the change in which we made SummaryMetadata.plugin_data a non-repeated field. You can confirm that in the source here: https://github.com/tensorflow/tensorflow/blob/b9ac2d7eb17022a677597a1f88a65d8d26278088/tensorflow/core/framework/summary.proto#L53

So the problem is simply that you are running incompatible versions of TensorBoard and TensorFlow.

Some possibilities:

  • Is it possible to build TensorFlow with cudnn7.0 support against HEAD? This would be the best option.
  • Is it possible to build TF+cudnn7.0 against 4c60c96257bfd54a036d15af979e90fc0b4e400d?
  • If neither of the above two is possible, it should certainly be possible to build TF+cudnn7.0 against db596594b5653b43fcb558a4753b39904bb62cbd~ but with 4c60c96257bfd54a036d15af979e90fc0b4e400d cherry-picked in, and this should be sufficient resolve the issue (at the risk of using a TensorFlow codebase that was never actually the state of the repository at any time).
  • If for some reason that is not possible either, you'll have to downgrade TensorBoard to 0.1.2, I think.

wchargin avatar Oct 13 '17 18:10 wchargin

@wchargin I tried your first and third solutions and both resolve the issue. Now the tensorflow version on out machine is 1.4.0rc0. Thanks again for your help!

@soloice You may close the issue no and enjoy new tensorboard on our server.

FireBrother avatar Oct 14 '17 04:10 FireBrother

Now we have TensorFlow 1.4.0-rc0 and TensorBoard 0.4.0rc1 with cuDNN 7.0 support. That's awesome! @wchargin You really helped a lot! Many thanks!

soloice avatar Oct 14 '17 04:10 soloice

Great, glad to hear it. You're very welcome!

wchargin avatar Oct 14 '17 11:10 wchargin