Torch+cuda installation on CPU-only machine


Question: Is it feasible to install a CUDA-compatible version of torch (and torchvision) on a machine without a GPU (and no CUDA installed) (e.g. pip install pip install torch==1.10.1+cu111)?

Context: I want to declare torch as a dependency in my packaging meta-data. The project is a plug-in for a GUI-based software → intended for users without command line experience. Further, torch must be functional irrespective of OS and on GPU and CPU machines. However, automatically recognising if the machine has GPUs available at installation time does not seem to be possible (?, currently using poetry).

Similar issues have been discussed here:


pip install torch torchvision will install the default wheels hosted on PyPI, which ship with the CUDA 11.7 runtime, so it seems this would already solve your issue.

ok, so do I understand you correctly, that installing a torch version that ships with e.g. CUDA 11.7 does not introduce unintended behaviour on a machine that does not have GPUs available?

Yes, I don’t think installing the default pip wheels with the CUDA 11.7 runtime has any side effects besides the size increase (since CUDA libs will be downloaded and stored).

1 Like