Closed maym86 closed 4 years ago
Figured it out
add torch.set_default_tensor_type('torch.cuda.FloatTensor')
to the top of demo_test.py
and add .cuda() to this line in demo_test.py def main()
around line 60
x = transform_to_net({'img': img})['img'].cuda()
Hi @maym86. Can you please help me with running the demo on GPU? I did change what you suggested in your second comment, however, still, some errors are there. Should I also consider the proposed changes in your first comment? Thanks!
Try it. I can't remember tbh. Been a few years since I did this. Sorry.
@vabrishami Maybe you can change map_location='cuda'
to map_location='cpu'
.
Thanks @harryhan618 and @maym86. I made the following changes to make it work:
1- After net.eval() line, add a new line with net.cuda() 2- Change x = transform_to_net({'img': img})['img'].cpu() to x = transform_to_net({'img': img})['img'].cuda()
That's it. With these changes, I could run it on GPU.
Hello,
I am running the demo_test.py script successfully but it seems to be using the cpu.
I tried a few things including setting the map_location to cuda:
save_dict = torch.load(weight_path, map_location='cuda')
And setting the model to cuda() in model.py. But neither of these seem to make any difference.
Any ideas?