2

When creating a new mamba (conda) environment, I only get Pytorch's CPU package. Does anyone know how to ensure/force the GPU version?

Even if, the first thing I installed is cudatoolkit it keeps getting the CPU package. I tried with version 11.6 and 11.3, nothing changed.

This is the command I used:

mamba install pytorch torchvision torchaudio -c pytorch -c conda-forge

  + pytorch                              1.13.0  py3.9_cpu_0        pytorch/win-64          145MB
  + pytorch-mutex                           1.0  cpu                pytorch/noarch            3kB
  + requests                             2.28.1  pyhd8ed1ab_1       conda-forge/noarch     Cached
  + tbb                                2021.6.0  h91493d7_1         conda-forge/win-64      178kB
  + torchaudio                           0.13.0  py39_cpu           pytorch/win-64            5MB
  + torchvision                          0.14.0  py39_cpu           pytorch/win-64            7MB

Before you ask: my GPU is available and in other environments I successfully use Pytorch with GPU.

Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55
Diewyns
  • 21
  • 2
  • 1
    I noticed that it get the pytorch 1.13.0 so i tried `mamba install pytorch==1.12.1 torchvision torchaudio -c pytorch -c conda-forge` and i worked, I got the cuda packages So the problem is solved !!!! – Diewyns Oct 28 '22 at 11:58

2 Answers2

2

The command you use is the one officially recommended by PyTorch documentation.

Failure seems to be down to a new version of Pytorch (1.13) having appeared on conda-forge recently and the GPU version seems to have some dependency problems (https://anaconda.org/pytorch/pytorch/files).

Unfortunately, there does not seem to be a way to specify that one wants to have the GPU version installed. The default seems to be to install the newest version, and fall back to CPU if GPU does not work. In your case, you care more about having GPU support than being on the latest Pytorch version.

The solution is to specify pytorch==1.12.1 as you remarked in a comment:

mamba install pytorch==1.12.1 torchvision torchaudio -c pytorch -c conda-forge

Here's the error I get when trying to force Pytorch 1.13 with GPU:

❯ mamba create -n testtorch pytorch=1.13=py3.10_cuda11.6_cudnn8_0 torchvision torchaudio cudatoolkit -c pytorch/noarch -c pytorch/win-64 -c conda-forge/win-64 -c conda-forge/noarch --override-channels -d
...
Looking for: ['pytorch==1.13=py3.10_cuda11.6_cudnn8_0', 'torchvision', 'torchaudio', 'cudatoolkit']

pytorch/noarch                                              Using cache
pytorch/win-64                                              Using cache
conda-forge/win-64                                          Using cache
conda-forge/noarch                                          Using cache
Encountered problems while solving:
  - nothing provides cuda 11.6.* needed by pytorch-cuda-11.6-h867d48c_0

I've made a Pytorch bug report here: https://github.com/pytorch/pytorch/issues/87991

To install version 1.13.0 with GPU support, run:

conda install pytorch=1.13.0 torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55
0

@Cornelius Roemer: do you see the same thing if you ran the installation with 'conda' instead of 'mamba'? I ran into the same problem when trying to build a really old environment with pytorch==1.2.0, and switching to 'conda env create' actually helped.