If you try to restrict torch to not see any CUDA devices it will still find it and break on the first call with no CUDA-capable device is detected.
zagoruys@rio:~$ CUDA_VISIBLE_DEVICES= ipython
In [1]: import torch.cuda
In [2]: torch.cuda.is_available()
Out[2]: True
In [3]: if torch.cuda.is_available():
...: x = torch.cuda.FloatTensor()
...:
THCudaCheck FAIL file=/home/zagoruys/rocks/pytorch/torch/lib/THC/THCGeneral.c line=62 error=38 : no CUDA-capable device is detected
terminate called after throwing an instance of 'THException'
what(): cuda runtime error (38) : no CUDA-capable device is detected at /home/zagoruys/rocks/pytorch/torch/lib/THC/THCGeneral.c:62
Aborted (core dumped)
If you try to restrict torch to not see any CUDA devices it will still find it and break on the first call
with no CUDA-capable device is detected.