Installing cudatoolkit works with conda install but not with conda create -f

Viewed 643

I have a PyTorch environment file:

name: torch
channels:
  - defaults
  - conda-forge
dependencies:
  - python=3.7
  - pytorch::pytorch
  - pytorch::torchvision
  - pytorch::torchaudio
  - pytorch::cudatoolkit
  - numpy
  - scipy
  - scikit-learn
  - matplotlib
  - pillow
  - tqdm
  - joblib
  - visdom
  - jsonpatch
  - pip
  - pip:
    - torchsummary
    - opencv-python==4.1.1.26

Trying to create a conda environment from it with conda create -f torch.yml fails:

(base) prompt@PC:~$ conda env create -f environment.yml 
Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound: 
  - pytorch::cudatoolkit

The environment is created without issues if I remove cudatoolkit from the list of dependencies.

However, conda install cudatoolkit -c pytorch finds and installs the package without issues. The same happens if I replace cudatoolkit with cudatoolkit=11.3 (the current most recent version listed on the PyTorch website) in both cases.

2 Answers

You have that error because there is no package called pytorch::cudatoolkit found by conda.

You yml env file have to look like this:

name: torch
channels:
  - defaults
  - conda-forge
  - pytorch
dependencies:
  - python=3.7
  - pytorch
  - torchvision
  - torchaudio
  - cudatoolkit=11.3
  - numpy
  - scipy
  - scikit-learn
  - matplotlib
  - pillow
  - tqdm
  - joblib
  - visdom
  - jsonpatch
  - pip
  - pip:
    - torchsummary
    - opencv-python==4.1.1.26

I managed to resolve the issue by installing cudatoolkit from the nvidia channel, rather than pytorch. I'm still not sure why cudatoolkit is available from pytorch with one method but not the other, but this solves my issue (although the nvidia version seems to be larger, so it's probably a superset package of pytorch's cudatoolkit). My YAML file now looks like this:

name: ritnet
channels:
  - defaults
  - conda-forge
dependencies:
  - python=3.7
  - pytorch::pytorch
  - pytorch::torchvision
  - pytorch::torchaudio
  - nvidia::cudatoolkit=11.3
  - numpy
  - scipy
  - scikit-learn
  - matplotlib
  - pillow
  - tqdm
  - joblib
  - visdom
  - jsonpatch
  - pip
  - pip:
    - torchsummary
    - opencv-python==4.1.1.26
Related