Skip to content

Instantly share code, notes, and snippets.

@Hanrui-Wang
Created September 16, 2019 22:53
Show Gist options
  • Save Hanrui-Wang/e71e42a6182e20d9ecd43e157638f49e to your computer and use it in GitHub Desktop.
Save Hanrui-Wang/e71e42a6182e20d9ecd43e157638f49e to your computer and use it in GitHub Desktop.
measure the latency of pytorch program execution
start = torch.cuda.Event(enable_timing=True)
end = torch.cuda.Event(enable_timing=True)
start.record()
z = x + y
end.record()
# Waits for everything to finish running
torch.cuda.synchronize()
print(start.elapsed_time(end))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment