1

I have a requirements.txt from a Github repo that contains following lines:

torch>=1.7.0,!=1.12.0
torchvision>=0.8.1,!=0.13.0
// and more

As I search SO and google they say I need to install pytorch with cuda specified, e.g. +cu110; in order to enable GPU and use the installed cuda.

So, for example this command does work on CLI: pip install torch==1.7.1+cu110 -f https://download.pytorch.org/whl/torch_stable.html

But the problem is with requirements.txt.

I looked Install PyTorch from requirements.txt - Stack Overflow and tried some solutions but they didn't work as the following.

// simply added `+cu110`
// didn't work
torch>=1.7.0+cu110,!=1.12.0
torchvision>=0.8.1+cu110,!=0.13.0
// w/ --extra-index-url
// didn't work
--extra-index-url https://download.pytorch.org/whl/cu110
torch>=1.7.0+cu110,!=1.12.0
--extra-index-url https://download.pytorch.org/whl/cu110
torchvision>=0.8.1+cu110,!=0.13.0
// w/ -f
// didn't work
-f https://download.pytorch.org/whl/torch_stable.html
torch>=1.7.0+cu110,!=1.12.0
-f https://download.pytorch.org/whl/torch_stable.html
torchvision>=0.8.1+cu110,!=0.13.0

So, is it possible to work with the combination of >= and +cu110 in requirements.txt?

Edit

It still doesn't work with no +cu110.

The following doesn't install cuda, but instead installs a normal torch.

--extra-index-url https://download.pytorch.org/whl/cu110
torch>=1.7.0+cu110,!=1.12.0
--extra-index-url https://download.pytorch.org/whl/cu110
torchvision>=0.8.1+cu110,!=0.13.0

So the stdout result is like:

Collecting torch!=1.12.0,>=1.7.0
  Using cached torch-1.13.0-cp37-cp37m-win_amd64.whl (167.3 MB)

And pip freeze shows:

torch==1.13.0
torchvision==0.14.0

The following also doesn't install cuda.


-f https://download.pytorch.org/whl/cu110
torch>=1.7.0,!=1.12.0
-f https://download.pytorch.org/whl/cu110
torchvision>=0.8.1,!=0.13.0

The stdout and pip freeze result is the same to the above.

The following also doesn't work, it installs cuda, but it installs a random version of cuda. (it's understandable because I didn't specify a version I prefer)

-f https://download.pytorch.org/whl/torch_stable.html
torch>=1.7.0,!=1.12.0
-f https://download.pytorch.org/whl/torch_stable.html
torchvision>=0.8.1,!=0.13.0

The stdout:

Collecting torch!=1.12.0,>=1.7.0
  Using cached https://download.pytorch.org/whl/cu117/torch-1.13.0%2Bcu117-cp37-cp37m-win_amd64.whl (2258.1 MB)
Collecting torchvision!=0.13.0,>=0.8.1
  Using cached https://download.pytorch.org/whl/cu117/torchvision-0.14.0%2Bcu117-cp37-cp37m-win_amd64.whl (4.8 MB)

pip freeze result:

torch==1.13.0+cu117
torchvision==0.14.0+cu117

0 Answers0