Can't see graph using torch.utils.tensorboard
I'm trying to get used to tensorboard, and I code my models using pytorch. 
However when I try to see my model using the add_graph() function, I've got this: 

With this as the test code:

import numpy as np
import torch
import torchvision.transforms as transforms
import torch.nn as nn
import torch.optim as optim
from torch.utils.tensorboard import SummaryWriter

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.linear = nn.Linear(2, 1)

    def forward(self, x):
        x = self.linear(x)
        return x

writer = SummaryWriter('runs_pytorch/test')
net = Net()
criterion = nn.CrossEntropyLoss()
optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)
writer.add_graph(net, torch.zeros([4, 2], dtype=torch.float))
writer.close()


On the other hand, if I try to see a graph using TensorFlow, everything seems fine:


with this as the test code this time:

import tensorflow as tf
tf.Variable(42, name='foo')
w = tf.summary.FileWriter('runs_tensorflow/test')
w.add_graph(tf.get_default_graph())
w.flush()
w.close()


In case you are wondering, I'm using this command to start tensorboard:

tensorboard --logdir runs_pytorch


Something I noticed is that when I use it on the directory allocated for my tensorflow test, I've got the usual message with the address, but if I do the same thing with  --logdir runs_pytorch I've got something more:

W1010 15:19:24.225109 15308 plugin_event_accumulator.py:294] Found more than one graph event per run, or there was a metagraph containing a graph_def, as well as one or more graph events.  Overwriting the graph with the newest event.
W1010 15:19:24.226075 15308 plugin_event_accumulator.py:322] Found more than one "run metadata" event with tag step1. Overwriting it with the newest event.

I'm on windows, I tried on different browsers (chrome, firefox...).
I have tensorflow 1.14.0, torch 1.2.0, Python 3.7.3

Thank you very much for your help, it's driving me crazy! 

There are two ways to solve it:

1. update PyTorch to 1.3.0 and above:


conda way:

    conda install pytorch torchvision cudatoolkit=9.2 -c pytorch

pip way:

    pip3 install torch==1.3.0+cu92 torchvision==0.4.1+cu92 -f https://download.pytorch.org/whl/torch_stable.html



2. install tensorboardX instead:


uninstall tensorboard:

if your tensorboard is installed by pip:

    pip uninstall tensorboard


if your tensorboard is installed by anaconda:

    conda uninstall tensorboard

install tensorboardX

    pip install tensorboardX

when writing script,
change

    from torch.utils.tensorboard import SummaryWriter


to 

    from tensorboardX import SummaryWriter


