[TIP / Installation] requirements.txt 로 pytorch package 설치하는 방법

2020. 10. 25. 16:21분석 Python/Pytorch

728x90

 

보통 다른 패키지들은 아래와 같은 freeze를 이용해서 파일을 하나 생성하고 설치하면 정상적으로 설치가 된다.

pip freeze > requirements.txt
pip install -r requirements.txt

 

보통 requirements.txt 파일은 아래와 같이 생성된다.

scikit-learn==0.23.2
scipy==1.5.3
seaborn==0.11.0
shap==0.36.0
six==1.15.0
slicer==0.0.4
statsmodels==0.12.0
tabulate==0.8.7
threadpoolctl==2.1.0
torch==1.6.0+cpu
torchvision==0.7.0+cpu

하지만 이렇게 해서 설치를 하면, torch를 설치할 때 에러가 발생하게 된다.

 

그래서 검색을 해보니, 아래와 같은 방법을 추천해주니 설치가 되었다!!

 

바로 link도 같이 넣어주는 것이다.

 

아래와 같이 --find-links를 통해서 파일 설치 경로를 달아주면 설치가 되는 것을 확인할 수 있다

statsmodels==0.12.0
tabulate==0.8.7
threadpoolctl==2.1.0
--find-links https://download.pytorch.org/whl/torch_stable.html
torch==1.6.0+cpu

 

생각해보면 pip로 파이토치를 설치할 때, 항상 링크가 필요했다.

-f의 의미가 find-links의 축약어로 생각된다.

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

 

결론은 pytorch를 설치할 때는 추가적으로 --find-links를 달아줘야 한다!

 


 

github.com/pytorch/pytorch/issues/29745

 

How to add PyTorch to requirements.txt · Issue #29745 · pytorch/pytorch

I'm trying to include PyTorch in a requirements.txt file to be installed in a Docker container, but can't seem to get it to work. I've tried adding the following with no luck: torch==1....

github.com

 

www.nuomiphp.com/eplan/en/143514.html

 

Install PyTorch from requirements.txt - 糯米PHP

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 instal

www.nuomiphp.com

 

728x90