Torch.profiler with tensorboard didn't work

username: Yiqun_Chen
cooked: <p>Hi guys, I tried <a href="https://pytorch.org/tutorials/intermediate/tensorboard_profiler_tutorial.html?highlight=profile" rel="noopener nofollow ugc">Pytorch Profiler with Tensorboard tutorial</a>, but when I launch tensorboard, the terminal gives the following output:</p>
<blockquote>
<p>…<br>
W0222 11:06:25.349957 139955019081472 event_parser.py:80] 1 Runtime with external id 16841 don’t correlate to any operator!<br>
W0222 11:06:25.349983 139955019081472 event_parser.py:80] 1 Runtime with external id 16842 don’t correlate to any operator!<br>
W0222 11:06:25.350009 139955019081472 event_parser.py:80] 1 Runtime with external id 16843 don’t correlate to any operator!<br>
W0222 11:06:25.350035 139955019081472 event_parser.py:80] 1 Runtime with external id 16844 don’t correlate to any operator!<br>
W0222 11:06:25.350062 139955019081472 event_parser.py:80] 1 Runtime with external id 16845 don’t correlate to any operator!<br>
W0222 11:06:25.350090 139955019081472 event_parser.py:80] 1 Runtime with external id 16846 don’t correlate to any operator!<br>
W0222 11:06:25.350117 139955019081472 event_parser.py:80] 1 Runtime with external id 16847 don’t correlate to any operator!<br>
W0222 11:06:25.350143 139955019081472 event_parser.py:80] 1 Runtime with external id 16848 don’t correlate to any operator!<br>
I0222 11:06:25.475616 139955019081472 plugin.py:373] Run resnet18 loaded<br>
I0222 11:06:25.476129 139955027474176 plugin.py:343] Add run resnet18</p>
</blockquote>
<p>and tensorboard:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/b/4bbf990975647fee48cfed57e2a0de84ab2c026c.png" data-download-href="https://discuss.pytorch.org/uploads/default/4bbf990975647fee48cfed57e2a0de84ab2c026c" title="Screenshot (1)"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/4/b/4bbf990975647fee48cfed57e2a0de84ab2c026c_2_690x334.png" alt="Screenshot (1)" data-base62-sha1="aO6j0S0ukRKHkp0MV3KlveZSfmY" width="690" height="334" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/4/b/4bbf990975647fee48cfed57e2a0de84ab2c026c_2_690x334.png, https://discuss.pytorch.org/uploads/default/optimized/3X/4/b/4bbf990975647fee48cfed57e2a0de84ab2c026c_2_1035x501.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/4/b/4bbf990975647fee48cfed57e2a0de84ab2c026c_2_1380x668.png 2x" data-dominant-color="F9F3ED"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot (1)</span><span class="informations">1899×921 45.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>My code:</p>
<pre><code class="lang-auto">import torch
import torch.nn
import torch.optim
import torch.profiler
import torch.utils.data
import torchvision.datasets
import torchvision.models
import torchvision.transforms as T
transform = T.Compose(
    [T.Resize(224),
     T.ToTensor(),
     T.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
train_set = torchvision.datasets.CIFAR10(root='./data', train=True, download=True, transform=transform)
train_loader = torch.utils.data.DataLoader(train_set, batch_size=32, shuffle=True)
device = torch.device("cuda:7")
model = torchvision.models.resnet18(pretrained=True).cuda(device)
criterion = torch.nn.CrossEntropyLoss().cuda(device)
optimizer = torch.optim.SGD(model.parameters(), lr=0.001, momentum=0.9)
model.train()
def train(data):
    inputs, labels = data[0].to(device=device), data[1].to(device=device)
    outputs = model(inputs)
    loss = criterion(outputs, labels)
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()
with torch.profiler.profile(
        schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=2),
        on_trace_ready=torch.profiler.tensorboard_trace_handler('./log/resnet18'),
        record_shapes=True,
        profile_memory=True,
        with_stack=True
) as prof:
    for step, batch_data in enumerate(train_loader):
        if step &gt;= (1 + 1 + 3) * 2:
            break
        train(batch_data)
        prof.step()  # Need to call this at the end of each step to notify profiler of steps' boundary.
</code></pre>
<p>I am using PyTorch 1.10.2, tensorboard 2.6.0 and torch-tb-profiler 0.2.1.<br>
I would be grateful if anyone can give me some suggestions. Thanks!</p>