I have two version of CUDA installed on my Ubuntu 16.04 machine: 9.0 and 10.1.
They are located in /usr/local/cuda-9.0
and /usr/local/10.1
respectively.
If I install PyTorch 1.6.0 (which needs CUDA 10.1) via pip (pip install torch==1.6.0
), it uses version 9.0 and thus detects no GPUs. I already changed my LD_LIBRARY_PATH
to "/usr/local/cuda-10.1/lib64:/usr/local/cuda-10.1/cuda/extras/CUPTI/lib64"
but PyTorch is still using CUDA 9.0.
How do I tell PyTorch to use CUDA 10.1?
Asked
Active
Viewed 1.7k times
6

infochip
- 143
- 1
- 2
- 7
-
PyTorch doesn't use the system cuda when installed via pip or conda. It comes delivered with its own version of cuda. How have you determined that your pytorch is using cuda 9.0? What model of GPU do you have? – jodag Feb 09 '21 at 09:59
-
I checked the CUDA version with `torch._C._cuda_getDriverVersion()` which gives `9000`. If PyTorch comes with it's own CUDA, why does it use a version that is incompatible? – infochip Feb 09 '21 at 10:17
-
My GPU is a NVIDIA GeForce GTX 1080 – infochip Feb 09 '21 at 10:19
-
`torch._C._cuda_getDriverVersion()` is not the cuda version being used by pytorch, it is the latest version of cuda supported by your GPU driver (should be the same as reported in `nvidia-smi`). The value it returns implies your drivers are out of date. **You need to update your graphics drivers to use cuda 10.1**. The version of cuda actually being used by pytorch can be queried with `torch.version.cuda` (assuming one is actually being used). See [this answer](https://stackoverflow.com/a/61034368/2790047) for more info on system requirements for installing pytorch with cuda support. – jodag Feb 09 '21 at 11:13
-
I'm guessing you choose to install the "compatible drivers" option when installing the CUDA 9.0 toolkit. This was likely a mistake as it probably installed old drivers distributed with the 9.0 toolkit. – jodag Feb 09 '21 at 11:18
-
Thanks for the clarification - that was indeed the problem – infochip Feb 10 '21 at 07:27
1 Answers
7
Prebuilt wheels for torch built with different versions of CUDA are available at torch stable releases page. For example you can install torch v1.9.0 built with CUDA v11.1 like this:
pip install --upgrade torch==1.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
But not all the combinations are available.

Mehraban
- 3,164
- 4
- 37
- 60