Can I install pytorch cpu + any specified version of cudatoolkit?

Viewed 542

My remote has cuda==11.0 and I want to install pytorch on it.

I use the command conda install pytorch cudatoolkit=11.0 -c pytorch -c conda-forge but in the installation list:

cudatoolkit        conda-forge/linux-64::cudatoolkit-11.0.3-h15472ef_8
pytorch            pytorch/linux-64::pytorch-1.10.0-py3.8_cpu_0

I found that pytorch is a cpu one.

Alternatively, I substitute 11.0 with 11.1 and the installation list appears to be:

cudatoolkit        conda-forge/linux-64::cudatoolkit-11.1.1-h6406543_8
pytorch            pytorch/linux-64::pytorch-1.10.0-py3.8_cuda11.1_cudnn8.0.5_0

where pytorch is a gpu one.

My question is: are the above two installation essentially same? If not, how can I install pytorch=1.10.0 with cuda==11.0?

I'd also like to know how does the cuda compatibility work? Is a cudatoolkit==11.1 compatible with programs compiled with cudatoolkit==11.0?

1 Answers

It all depends on whether the pytorch channel has built a version against the particular cudatoolkit version. I don't know a specific way to search this, but one can browse what builds are available on the pytorch channel. For PyTorch 1.10 on linux-64 platform it appears only CUDA versions 10.2, 11.1, and 11.3 are available.

As mentioned in the comments, one can try forcing a CUDA build of PyTorch with

conda create -n foo -c pytorch -c conda-forge cudatoolkit=11.0 'pytorch=*=*cuda*'

which would fail in this combination.

As for compatibility, no, the pytorch package builds lock in the minor version of cudatoolkit. For example,

enter image description here

Related