공부하며 성장하기/Fixing Errors
requirements.txt에서 URL로 PyTorch 설치하기
나는조이
2022. 9. 21. 05:25
torch를 설치할 때 보통 여기서 다음 명령을 복사해 설치한다.pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
그런 다음 pip freeze > requirements.txt
로 다음과 같은 requirements.txt 파일을 만들 수 있다.
# requirements.txt
albumentations==1.3.0
numpy==1.23.3
pytorch==1.12.0+cu113
torchvision==0.13.0+cu113
torchaudio==0.12.0+cu113
하지만 이를 그대로 다시 pip install -r requirements.txt
로 설치하면 다음과 같은 에러가 난다.
ERROR: Could not find a version that satisfies the requirement torchaudio===0.12.0+cu113 (from versions: 0.6.0, 0.7.0, 0.7.1, 0.7.2, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.11.0, 0.12.0)
ERROR: No matching distribution found for torchaudio===0.12.0+cu113
이럴 때에는 requirements.txt에 설치하기 위한 URL을 함께 써야 한다.
# requirements.txt
albumentations==1.3.0
numpy==1.23.3
--extra-index-url https://download.pytorch.org/whl/cu113
pytorch==1.12.0+cu113
--extra-index-url https://download.pytorch.org/whl/cu113
torchvision==0.13.0+cu113
--extra-index-url https://download.pytorch.org/whl/cu113
torchaudio==0.12.0+cu113
반응형