Skip to content

Instantly share code, notes, and snippets.

@ilia-cher
Created February 3, 2021 11:11
Show Gist options
  • Save ilia-cher/0e78d0440fe02b77ff6721571c14f01c to your computer and use it in GitHub Desktop.
Save ilia-cher/0e78d0440fe02b77ff6721571c14f01c to your computer and use it in GitHub Desktop.
import torch
from torch.profiler import *
for with_cuda in [True, False]:
with profile() as prof:
x = torch.randn(2, 2)
if with_cuda:
x = x.cuda()
x = x.matmul(x)
print(prof.key_averages().table(sort_by="self_cpu_time_total", row_limit=-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment