szagoruyko / pytorchviz

A small package to create visualizations of PyTorch execution graphs
MIT License
3.24k stars 279 forks source link

JIT trace does not work with PyTorch 1.0 #27

Open szagoruyko opened 5 years ago

szagoruyko commented 5 years ago
ERROR: test_mlp_make_dot_from_trace (__main__.TestTorchviz)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 27, in test_mlp_make_dot_from_trace
    dot = make_dot_from_trace(trace)
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchviz/dot.py", line 133, in make_dot_from_trace
    list_of_nodes = parse(graph)
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchviz/dot.py", line 99, in parse
    inputs = [replace(i.uniqueName(), scope) for i in n.inputs()]
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchviz/dot.py", line 99, in <listcomp>
    inputs = [replace(i.uniqueName(), scope) for i in n.inputs()]
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchviz/dot.py", line 80, in replace
    return '/'.join([scope[name], name])
KeyError: 'input.1'

the solution is probably somewhere in https://github.com/lanpa/tensorboardX/blob/master/tensorboardX/pytorch_graph.py#L188

qianyuzqy commented 5 years ago

Hello! I have the same problem. The JIT Trace does not work with PyTorch 1.0. And I updated my pytorch_graph.py in tensorboardX as you said in https://github.com/lanpa/tensorboardX/blob/master/tensorboardX/pytorch_graph.py#L188 , but it dosen't work at all. Traceback (most recent call last): File "/home/zhouqy/home/zhouqy/tmp/Mofan_Pytorch/hello/test.py", line 38, in <module> make_dot_from_trace(trace) File "/home/zhouqy/anaconda3/lib/python3.6/site-packages/torchviz/dot.py", line 133, in make_dot_from_trace list_of_nodes = parse(graph) File "/home/zhouqy/anaconda3/lib/python3.6/site-packages/torchviz/dot.py", line 99, in parse inputs = [replace(i.uniqueName(), scope) for i in n.inputs()] File "/home/zhouqy/anaconda3/lib/python3.6/site-packages/torchviz/dot.py", line 99, in <listcomp> inputs = [replace(i.uniqueName(), scope) for i in n.inputs()] File "/home/zhouqy/anaconda3/lib/python3.6/site-packages/torchviz/dot.py", line 80, in replace return '/'.join([scope[name], name]) KeyError: 'input.1'

rojinsafavi commented 5 years ago

any updates?

afqueiruga commented 4 years ago

I think I fixed this one in the PR I just submitted.