I tried running the demo_graph.py and got the following error.
python demo_graph.py
Traceback (most recent call last):
File "demo_graph.py", line 56, in <module>
w.add_graph(model, (dummy_input, ))
File "/home/dana/Desktop/tensorboard-pytorch/tensorboardX/writer.py", line 400, in add_graph
self.file_writer.add_graph(graph(model, input_to_model, verbose))
File "/home/dana/Desktop/tensorboard-pytorch/tensorboardX/graph.py", line 52, in graph
trace, _ = torch.jit.trace(model, args)
TypeError: 'function' object is not iterable
The return of torch.jit.trace is this wrapper, from this commit
I'm using the Python 3.6 on Ubuntu 16.04
torch==0.4.0 built from sourcetensorboardX==1.1tensorboard==1.6.0Edit: Updated my pytorch version
can't reproduce :(
torch==0.3.1, tensorboardX==1.1
The 0.3.1 is from conda. Did you install 0.3.1 from source? Not sure if there are differences...
Oh yeah, I installed from source actually. My GPU is a bit old.
On Sun, Mar 11, 2018, 18:27 Tzu-Wei Huang notifications@github.com wrote:
can't reproduce :(
torch==0.3.1, tensorboardX==1.1The 0.3.1 is from conda. Did you install 0.3.1 from source? Not sure if
there are differences...—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/lanpa/tensorboard-pytorch/issues/99#issuecomment-372132747,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEcLWZonzLey5JKhc76hh2T4Io1LYqvGks5tdV6CgaJpZM4SlWbQ
.
Since you build from source, why not go for 0.4 lol. Another choice is to install pytorch-cpu in virtual env for graph plotting.
Thanks for pointing this out. It turns out that I was actually using PyTorch 0.4.0. My initial mistake in report 0.3.1 was due to the fact that torchvision had installed conda's pytorch. Anyhow, the problem I suppose is still with 0.4 and goes back to the wrapper function I pointed to initially.
I'll try with pytorch-cpu, thanks
@lanpa Hi, I also tried running the demo_graph.py, but the graph on tensorboard is like

I don't know why it performs like this and how to correctly show the graphs of the networks. I'm using the Python 3.5 on Ubuntu 14.04
torch==0.3.1 from conda
tensorboardX=1.1
tensorboard =1.6.0
Edit: Wow, I missed the expanding button, so embarrassing =_=
Why is this issue closed? Was anyone able to reproduce the issue with pytorch 0.4?
@danakianfar I thought pytorch-cpu works for you. Have you tried with newest pytorch 0.4?
@lanpa Sorry, I messed up originally with my description. I only had pytorch 0.4 initially so the problem is in fact with pytorch 0.4. I think I figured it out though, I'm preparing a pull request now.
I don't think this issue has been fixed
For Python 3.5.4 on Ubuntu 16.04
torch==0.4.0 built from source
tensorboardX==1.1
tensorboard==1.6.0
I reproduced the issue exactly
@xiongzhp Perhaps you can try this pull request and let us know if it also works for you
@danakianfar Thank you so much! Because I just installed TensorboardX from source, I thought your pull request has been merged, but not yet. I tried your code, it works great.
RuntimeError: Only tuples, lists and Variables supported as JIT inputs, but got numpy.ndarray
Is this error in #109 related to the current issue?
demo_graph.py works perfectly. But if I try to save my own model it gives this error:
Error occurs, checking if it's onnx problem...
Your model fails onnx too, please report to onnx team
No graph saved
Also is this bug rectified now?
@backpropper Because add_graph is based on onnx and some operation in your model cannot exported by onnx. you have to file a issue to them. The bug you mentioned should be solved, I will test it later. (Did the code print your model on terminal? That will be big help)
I mee the the error, my model is torchvision.models.AlexNet
Your model fails onnx too, please report to onnx team
@WenmuZhou Does the error come from demo_graph.py?
@lanpa I have fixed my error, the code write network to tensorboard must before model.to(device)
model = torchvision.models.AlexNet(num_classes=10)
# 准备写tensorboard, 必须放在'.to(device)'之前,不然会报错
writer = SummaryWriter()
dummy_input = torch.autograd.Variable(torch.rand(1, 3, 227, 227))
writer.add_graph(model=model, input_to_model=(dummy_input, ))
model = model.to(device)
so the input data and the model must on same device
so ,how should i do to fix this problem?
Error occurs, No graph saved
Checking if it's onnx problem...
Your model fails onnx too, please report to onnx team
torch = 0.4.1 (from conda)
tensorboard = 1.8
tensorboardX = 1.4
here is my code:
`
cfg = './cfg/yolov3.cfg'
model = DarkNet(cfg)
imgfile = 'dog-cycle-car.png'
img = get_test_input(imgfile)
print (model)
print (img)
with SummaryWriter(comment='DarkNet') as w:
w.add_graph(model,input_to_model = img)
`
what should i do?@lanpa
Thank you so much!!
@xwjBupt Would you like test your code with pytorch 1.0.0 + tensorboardX1.5?
PyTorch (torch) version: 1.0.1.post2
Tensorboard version: 1.12.0
TensorboardX version: 1.6
Running demo_graph.py
Generates the following error:
expect error here:
Error occurs, No graph saved
Checking if it's onnx problem...
Your model fails onnx too, please report to onnx team
And the graph looks like this:

How should I fix this issue? (@lanpa)
In my case, a model not on GPU but on CPU was correctly displayed. However, RNN models didn't seem to be supported by ONNIX anyway.
@snehilverma41 notice the expect error here: line in the output. To my understanding, this error is expected. Check the source code.
Regarding your graph output, that seems like the correct graph for the LinearInLinear Module. To view graphs of other modules, try the run dropdown in tensorboard:

@ywatanabe1989 Not sure what RNN are you using, but those in demo_graph.py should work with onnx. BTW in tensorboardX v1.8 ONNX is replaced by JIT so more pytorch models should be supported now.
Closing this as pytorch 0.4 is legacy and totally new implementation of add_graph is release in tensorboardX 1.8. Please open a new issue if needed. (and follow the issue template)
Most helpful comment
Why is this issue closed? Was anyone able to reproduce the issue with pytorch 0.4?