$ python -m line_profiler .\exp.py.lprof Timer unit: 1e-06 s
Total time: 0.0036551 s File: ./exp.py Function: calculation at line 4
Line # Hits Time Per Hit % Time Line Contents ============================================================== 4 @profile 5 def calculation(): 6 1 0.4 0.4 0.0 x = 1 7 10001 1724.8 0.2 47.2 for i in range(10000): 8 10000 1929.7 0.2 52.8 x += i 9 1 0.2 0.2 0.0 return x
from torch.profiler import profile, record_function, ProfilerActivity
with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA], with_stack=True, record_shapes=True) as prof: with torch.no_grad(): start_time = time.time() for i in range(100): s = model(dummy_graph) end_time = time.time() print("CUDA FP32 time: ", (end_time - start_time) / 10)