Elapsed Time Units

I was using this to measure the time on the GPU, and I was wondering what the units of the output were.

torch.cuda.synchronize()
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))

Does this print the elapsed time in seconds or milliseconds? I looked at the source, and it looks like milliseconds, but I wanted to be certain.

It is indeed milliseconds. We should add the units to the documentation (https://pytorch.org/docs/master/cuda.html?highlight=cuda%20event#torch.cuda.Event), I have to look this up once in a while

2 Likes