Install PyTorch from requirements.txt

百般思念 提交于 2021-02-04 15:24:50

问题


Torch documentation says use

pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

to install the latest version of PyTorch. This works when I do it manually but when I add it to req.txt and do pip install -r req.txt, it fails and says ERROR: No matching distribution.

Edit: adding the whole line from req.txt and error here.

torch==1.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.htmltorch==1.4.0+cpu
ERROR: Could not find a version that satisfies the requirement torch==1.4.0+cpu (from -r requirements.txt (line 1)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0)
ERROR: No matching distribution found for torch==1.4.0+cpu (from -r requirements.txt (line 1))

回答1:


Add --find-links in requirements.txt before torch

--find-links https://download.pytorch.org/whl/torch_stable.html

torch==1.2.0+cpu

Source: https://github.com/pytorch/pytorch/issues/29745#issuecomment-553588171




回答2:


-f https://download.pytorch.org/whl/torch_stable.html 
torch==1.4.0+cpu 
-f https://download.pytorch.org/whl/torch_stable.html
torchvision==0.5.0+cpu

worked fine for me :)




回答3:


You can do something like that:

$ pip install -r req.txt --find-links https://download.pytorch.org/whl/torch_stable.html

Just put your PyTorch requirements in req.txt like this:

torch==1.4.0+cpu

torchvision==0.5.0+cpu



来源:https://stackoverflow.com/questions/60912744/install-pytorch-from-requirements-txt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!