Skip to content

torch.cuda.is_available is True with CUDA_VISIBLE_DEVICES= #306

@szagoruyko

Description

@szagoruyko

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions