Issue
I am trying to install a specific version of pytorch that is compatible with a specific cuda driver version with pipenv. The pytorch website shows how to to this with pip:
pip3 install torch==1.3.1+cu92 torchvision==0.4.2+cu92 -f https://download.pytorch.org/whl/torch_stable.html
I tried to convert this into an entry in my Pipfile
like this:
[[source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/torch_stable.html"
verify_ssl = false
pytorch = {version="==1.3.1+cu92", index="pytorch"}
torchvision = {version="==0.4.2+cu92", index="pytorch"}
However, this does not work. The dependency with this version can not be resolved. I am not sure if the url that is listed with the -f
parameter in the pip3
command is even a valid source for pipenv
.
I could install both libraries by just passing the command through to pip like this:
pipenv run pip install torch==1.3.1+cu92 torchvision==0.4.2+cu92 -f https://download.pytorch.org/whl/torch_stable.html
but I am not really satisfied with that solution since the dependencies are not in the Pipfile
and I have to manually document the usage of this command.
Solution
The problem with the approach above lies in the structure of https://download.pytorch.org/whl/torch_stable.html
. Pipenv can only find torch versions 0.1 to 0.4.1 because all others have the cuda (or cpu) version as a prefix e.g. cu92/torch-0.4.1-cp27-cp27m-linux_x86_64.whl
.
But the cuda version is a subdirectory. So if you change the url of the source to the cuda version and only specify the torch version in the dependencies it works.
[[source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu92"
verify_ssl = false
[packages]
torch = {index = "pytorch",version = "==1.4.0"}
The only problem I encountered is that numpy is not recognized as a dependency of pytoch 1.4.0. But this seems to be a problem of the specific pytorch wheel. With version 1.3.1 or 1.5.1 and a recent pipenv version it works.
So if after the installation with pipenv install
, the command pipenv run python -c "import torch"
throws an error, numpy must be added manually.
Answered By - moe
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.