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.

How do you use the new Pytorch Profiler with Ignite

See original GitHub issue

❓ Questions/Help/Support

Recently Pytorch announced a new profiling tool. Is there a way to use it with Ignite. The example code given in the blog post looks like:

 with torch.profiler.profile(
    schedule=torch.profiler.schedule(
        wait=2,
        warmup=2,
        active=6,
        repeat=1),
    on_trace_ready=tensorboard_trace_handler,
    with_trace=True
) as profiler:
    for step, data in enumerate(trainloader, 0):
        print("step:{}".format(step))
        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()
        profiler.step()

But the issue is that we don’t have access to the main for loop with Ignite. Is there an easy way to get it to work with ignite. I am assuming there should be a way using the event handlers (Event. EPOCH_STARTED) maybe?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
ryanwongsacommented, Apr 8, 2021

Never mind I see, I need to add an event to Event.EPOCH_STARTED with the following:

profiler = torch.profiler.profile(
    schedule=torch.profiler.schedule(
        wait=2,
        warmup=2,
        active=6,
        repeat=1),
    on_trace_ready=tensorboard_trace_handler,
    with_trace=True
) 

and then add to the update step:

profiler.step()
1reaction
arisliangcommented, Oct 27, 2021

@vfdev-5 thanks for the prompt reply!

Read more comments on GitHub >

github_iconTop Results From Across the Web

BasicTimeProfiler — PyTorch-Ignite v0.4.10 Documentation
High-level library to help with training and evaluating neural networks in PyTorch flexibly and transparently.
Read more >
How-to Guides - PyTorch-Ignite
Install PyTorch-Ignite from pip, conda, source or use pre-built docker images ... using Engine's State, BasicTimeProfiler and HandlersTimeProfiler.
Read more >
What is the new PyTorch profiler? - eduCBA
The Profiler makes use of a new GPU profiling engine that is based on Nvidia CUPTI APIs and can record GPU kernel activities...
Read more >
PROFILING AND OPTIMIZING PYTORCH APPLICATIONS ...
PyTorch Profiler is a tool that allows the collection of the performance metrics during the ... The Profiler's context API can be used...
Read more >
pytorch-ignite - PyPI
A lightweight library to help with training neural networks in PyTorch. ... Library approach and no program's control inversion - Use ignite where...
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