I tried to use such a function to determine cuda availability
and it returns ‘cuda:0’ on a device without Nvidia GPU at all.
Have anyone faced the same problem? Probably anyone has another solution?
That’s strange, as the script works even if I run it on a machine with a masked GPU:
CUDA_VISIBLE_DEVICES="" python your_script.py
EDIT: Wait a moment. I’ve run the script on the wrong machine.
torch.cuda.is_available() returning on your machine?
True. So I manually set
device='cpu' everytime I run code on my laptop without discrete graphics card
The script indeed works, i.e. masking the GPU returns ‘cpu’, while the plain call returns ‘cuda:0’ on my machine.
I’m sorry for a delay with a feedback. It seems that it was an issue with my env setup. I installed pytorch for GPU on a laptop without GPU. Updated to version 0.4.1 for CPU and everything works just fine.
pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision