I’m trying to export some stack information to generate flamegraphs by following this tutorial:
However, I can’t seem to get it work. Specifically, the generated file is always empty.
Here’s a snippet to reproduce:
#! /usr/bin/env python3
import torch
import torchvision.models as models
from torch.profiler import profile, record_function, ProfilerActivity
model = models.resnet18().cuda()
inputs = torch.randn(5, 3, 224, 224).cuda()
with profile(activities=[ProfilerActivity.CUDA], with_stack=True) as prof:
model(inputs)
prof.export_chrome_trace("trace.json")
prof.export_stacks("stacks.txt", metric="self_cuda_time_total")
stacks.txt is always empty. Does anyone have suggestions on what I should do?