Installing an older torch version with pip from environment.yml

In my worklflow I use a local module named predict which needs torch==1.5.0+cpu, but the installation of torch with pip fails.

In the /path/to/modules/local/predict/environment.yml I find torch like this:

pip: 
- torch==1.5.0+cpu

In a test environment my_env (with python 3.8.10), the command without the -f argument raises an error:

(my_env)$pip install torch==1.5.0+cpu
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
ERROR: Could not find a version that satisfies the requirement torch==1.5.0+cpu (from versions: 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1)
ERROR: No matching distribution found for torch==1.5.0+cpu

On the other hand, the command with the -f argument completes the installation.

(my_env)$pip install torch==1.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
...
Installing collected packages: numpy, future, torch
Successfully installed future-1.0.0 numpy-1.24.4 torch-1.5.0+cpu

How can I pass the argument -f https://download.pytorch.org/whl/torch_stable.html in pip install when installing an older version of torch from environment.yml?
Thank you.

An educated guess here - pytorch 1.5 likely only supports certain Python versions. In your host env, you have the correct version but the version installed by Conda is likely to be one of the latest versions. Can you try specifying the specific version of Python in your conda env?

It might be easier to use conda to install pytorch rather than pip which has notoriously poor dependency management: Pytorch | Anaconda.org

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.