Note that CUDA operations are executed asynchronously, so you would have to synchronize the code before starting and stopping timers.
I’m not deeply familiar with cProfile, but assume that it doesn’t synchronize the GPU internally.
The torch.utils.benchmark utils might be useful to compare different methods, as they will add warmup iterations and synchronize internally.