pipenv install pytorch cpu + specific version

1.3k Views Asked by At

I ned to install a specific version of pytorch cpu mode.

With pip I would do it like this:

pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html --trusted-host download.pytorch.org

How can I achieve the same using Pipenv?

I tried having the following Pipfile:

[[source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cpu"
verify_ssl = false

[packages]
torchvision = {index = "pytorch", version = "==0.4.0"}
torch = {index = "pytorch", version = "==1.2.0"}

but didn't work

1

There are 1 best solutions below

0
On

You can do:

$ PIP_FIND_LINKS="https://download.pytorch.org/whl/torch_stable.html" pipenv install torch==1.2.0+cpu torchvision==0.4.0+cpu

But, you'll have to ensure that you add PIP_FIND_LINKS for any consecutive pipenv sync, pipenv lock, etc.

UPD:

You may also add PIP_FIND_LINKS="https://download.pytorch.org/whl/torch_stable.html" to the .env file, but it's only being loaded on pipenv run and pipenv shell.