lanpa / tensorboardX

tensorboard for pytorch (and chainer, mxnet, numpy, ...)
https://tensorboardx.readthedocs.io/en/latest/tensorboard.html
MIT License
7.87k stars 864 forks source link

tensorboardX/examples/demo_graph.py -> AssertionError: %1 : Tensor = onnx::Constant[value={2}]() has empty scope name #441

Open vpapaioannou opened 5 years ago

vpapaioannou commented 5 years ago

Describe the bug I try to run tensorboardX/examples/demo_graph.py for jupyter notebook (launched by anaconda navigator) and I get the error seen at Additional context.

I just copy paste the code to notebook from Github.

Minimal runnable code to reproduce the behavior class SimpleModel(nn.Module): def init(self): super(SimpleModel, self).init()

   def forward(self, x):
        return x * 2

model = SimpleModel() dummy_input = (torch.zeros(1, 2, 3),)

with SummaryWriter(comment='constantModel') as w: w.add_graph(model, dummy_input, True)

Environment Windows, command : conda list | findstr proto, tensor, torch torch -> 1.1.0 libprotobuf -> 3.7.1 protobuf -> 3.5.2 tensorboard -> 1.13.1 tensorboardX -> 1.4 tensorflow -> 1.13.1 tensorflow-base -> 1.13.1 tensorflow-estimator -> 1.13.0 tensorflow-gpu -> 1.13.1

Additional context

AssertionError Traceback (most recent call last)

in 11 12 with SummaryWriter(comment='constantModel') as w: ---> 13 w.add_graph(model, dummy_input, True) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorboardX\writer.py in add_graph(self, model, input_to_model, verbose, **kwargs) 518 print('add_graph() only supports PyTorch v0.2.') 519 return --> 520 self.file_writer.add_graph(graph(model, input_to_model, verbose)) 521 except AttributeError: 522 # Caffe2 models do not have the 'forward' method ~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorboardX\pytorch_graph.py in graph(model, args, verbose) 102 if verbose: 103 print(graph) --> 104 list_of_nodes = parse(graph) 105 nodes = [] 106 node_stats = [] ~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorboardX\pytorch_graph.py in parse(graph) 22 23 uname = next(iter(n.outputs())).uniqueName() ---> 24 assert n.scopeName() != '', '{} has empty scope name'.format(n) 25 scope[uname] = n.scopeName() 26 if LooseVersion(torch.__version__) >= LooseVersion("0.4"): AssertionError: %1 : Tensor = onnx::Constant[value={2}]() has empty scope name
lanpa commented 5 years ago

tensorboardX v1.4 is old, please update.