Cuda device not found

I have just installed torch-0.4.0t on a virtualenv. Following Pytorch tutorials I have come to the point of running device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") print(device)
and it prints out cpu instead of cuda:0. So I go checking with other commands like: print ('Available devices ', th.cuda.device_count()) and still it does not seem to find my GPU (prints out zero).
Command cat /usr/local/cuda/version.txt returns CUDA Version 9.0.176 and my GPU is a GeForce 940MX.

Tried to install Pytorch again but nothing changed. Could anyone give me a hand please?

I had several issues with that in the past, too. Usually, the culprit was the graphics card driver / the graphic card not supporting certain versions of CUDA. I recommend uninstalling the version you have installed right now and to install the CUDA 8 version and check if this works. If it does work with CUDA 8.0-PyTorch, you would know that it’s the graphics card (driver), and otherwise, it would need further exploration. Let me know what you find.

Btw. the best (or quickest) way to check CUDA availability is by

import torch
1 Like

Thank you @rasbt for your reply. It works now with CUDA 9. Honestly, I am not sure about what fixed the issue, I just postponed the test with CUDA 8 for few days but it was no more necessary afterwards: I could use my GPU without problems.

glad to hear that it works now. maybe the machine just needed a reboot or so :wink: