lanpa / tensorboardX

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

add_graph results in `Invoked with: OperatorExportTypes.RAW, False` #197

Closed jleni closed 6 years ago

jleni commented 6 years ago

This snippet is based on demo_graph.py

torch == 0.4.1 tensorboardX == 1.2

import torch
from tensorboardX import SummaryWriter

log_dir = '/tmp/tbx'

class SimpleModel(torch.nn.Module):
    def __init__(self):
        super(SimpleModel, self).__init__()

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

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

with SummaryWriter(log_dir='/tmp/tbx') as w:
    w.add_graph(model, dummy_input)

This results in:


Traceback (most recent call last):
  File "/home/user/test_tb.py", line 20, in <module>
    w.add_graph(model, dummy_input)
  File "/home/user/anaconda3/envs/user/lib/python3.6/site-packages/tensorboardX/writer.py", line 419, in add_graph
    self.file_writer.add_graph(graph(model, input_to_model, verbose))
  File "/home/user/anaconda3/envs/user/lib/python3.6/site-packages/tensorboardX/graph.py", line 79, in graph
    torch.onnx._optimize_trace(trace, False)
  File "/home/user/anaconda3/envs/user/lib/python3.6/site-packages/torch/onnx/__init__.py", line 41, in _optimize_trace
    trace.set_graph(utils._optimize_graph(trace.graph(), operator_export_type))
  File "/home/user/anaconda3/envs/user/lib/python3.6/site-packages/torch/onnx/utils.py", line 106, in _optimize_graph
    if operator_export_type != OperatorExportTypes.RAW:
TypeError: __ne__(): incompatible function arguments. The following argument types are supported:
    1. (self: torch._C._onnx.OperatorExportTypes, arg0: torch._C._onnx.OperatorExportTypes) -> bool

Invoked with: OperatorExportTypes.RAW, False
lanpa commented 6 years ago

I guess this is caused by 0.4.1, which is not support yet.

lanpa commented 6 years ago

Hi, this should be solved in new pip release.

jleni commented 6 years ago

Thanks! I will test as soon as you make that available!

jleni commented 6 years ago

It is now working! Thank you!

h-jia commented 5 years ago

Seems happen the same issue with "Invoked with: OperatorExportTypes.RAW, False" with the pytorch 1.0.0, tensorboardX 1.2 for demo_graph.py.

Is there any plan for pytorch 1.0.0 update as official pytorch has updated?

lanpa commented 5 years ago

@h-jia There is v1.5 on PyPI. Or you can play with newest tensorboardX by checking out the source.