satyakrishnagorti:

Ok so I added torch.cuda.synchronize() before the timer.


Ok so I added torch.cuda.synchronize() before the timer.
>>> import time
>>> gpu_tensor = torch.randn(3,3).cuda()
>>> torch.cuda.synchronize()
>>> cpu_tensor = torch.randn(3,3)


>>> def test1():
        s = time.time()
        for i in range(50):
            torch.inverse(cpu_tensor)
        e = time.time()
        print(e - s)

>>> def test2():
        s = time.time()
        for i in range(50):
            torch.inverse(gpu_tensor)
        e = time.time()
        print(e - s)

>>> test1()
>>> 0.000277042388916

>>> test2()
>>> 0.325435876846

I still don’t see any improvement.