question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't add graph with pytorch v0.2

See original GitHub issue

I tried to run this snippet:

import torch
import torch.nn as nn
from torch.autograd import Variable
from datetime import datetime
from tensorboard import SummaryWriter


x = Variable(torch.rand(10, 10), requires_grad=True)

model = nn.Linear(10, 10)

h = model(x)

writer = SummaryWriter('runs/'+datetime.now().strftime('%B%d  %H:%M:%S'))

writer.add_graph(model, h)
writer.close()

but I get this error message:

Traceback (most recent call last):
  File "/Users/Miguel/Documents/Unbabel/pytorch-tools/tests/test_tensorboard.py", line 16, in <module>
    writer.add_graph(model, h)
  File "/Users/Miguel/anaconda/envs/venv/lib/python2.7/site-packages/tensorboard/writer.py", line 259, in add_graph
    self.file_writer.add_graph(graph(model, lastVar))
  File "/Users/Miguel/anaconda/envs/venv/lib/python2.7/site-packages/tensorboard/graph.py", line 39, in graph
    make_list_of_nodes(lastVar.grad_fn)
  File "/Users/Miguel/anaconda/envs/venv/lib/python2.7/site-packages/tensorboard/graph.py", line 23, in make_list_of_nodes
    inputs.append(make_name(next_fn))
  File "/Users/Miguel/anaconda/envs/venv/lib/python2.7/site-packages/tensorboard/graph.py", line 12, in make_name
    return id2name[id(obj.variable)]+'_'+str(id(obj.variable))
KeyError: 4654832816

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
miguelvrcommented, Aug 16, 2017

your solution works, but that shouldn’t make any difference lol

0reactions
lanpacommented, Dec 29, 2017

Since v0.2 is legacy, closing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PyTorch 2.0
PyTorch 2.x: faster, more pythonic and as dynamic as ever ... Dynamo will insert graph breaks at the boundary of each FSDP instance,...
Read more >
torch.utils.tensorboard — PyTorch 1.13 documentation
Create special chart by collecting charts tags in 'scalars'. Note that this function can only be called once for each SummaryWriter() object. Because...
Read more >
Transfer Learning: Adding graph to tensorboard, with the input
I cannot add this model to tensorboard to view the graph, even when I add the summary writer in the training loop. 2...
Read more >
torch.fx — PyTorch 1.13 documentation
This is done so if in case the operations in graph are n-ary (e.g. add is a binary operator) the call to Proxy...
Read more >
How to add graphs to hparams in tensorboard?
I'm trying to use tensorboard with pytorch and cannot find any clear documentation as to how to add graphs to the hparams dashboard....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found