mrshenli:

    print(f"DP execution time (ms) by CUDA event: {start.elapsed_time(end)}")
    torch.cuda.synchronize()



Shouldn’t it be
torch.cuda.synchronize()
print(f"DP execution time (ms) by CUDA event: {start.elapsed_time(end)}")

Coz I got RuntimeError: CUDA error: device not ready when execute your code as it is.