Get computation graph in tensorboard

How do I display computation graph in tensorboard from pytorch?

I logged my output images to tensorboard as follows:

import tensorflow as tf = tf
self.writer = tf.summary.FileWriter('path/to/log/dir')
img_summaries = []
for label, image_numpy in visuals.items():
      s = StringIO()
      s = BytesIO()
   scipy.misc.toimage(image_numpy).save(s, format="jpeg")
   img_sum =, height=image_numpy.shape[0], width=image_numpy.shape[1])
   img_summaries.append(, image=img_sum))
   summary =
   self.writer.add_summary(summary, step)

But when I try to add graph to tensorboard:

writer.add_graph(model, loss_1)

I get this error:

raise TypeError("The passed graph must be an instance of `Graph` "
TypeError: The passed graph must be an instance of `Graph` or the deprecated `GraphDef`
>>> print(torch.__version__)
>>> print(tensorflow.__version__)

What am I doing wrong here? Any help is appreciated. Thank you.


A pytorch model is not the same thing as a tensorboard Graph object. Unless you recreate a tensorflow Graph similar to your model you can’t do that. And even doing that might be tricky as there are some operations that are not the same between the two frameworks.
Maybe something like tensorboard-pytorch could help you.