카테고리 없음
PyTorch 버전 오류 해결 방법: PyTorch를 원하는 버전으로 다시 설치하는 방법 Feat. torch._six 오류
개발자의 잡동사니
2023. 7. 22. 07:55
※ 본 글은 필자의 경험에 근거하여 작성되었으며, 잘못된 정보가 포함될 수 있습니다. ※
어느날 필자에게 하나의 오류가 다가왔다. 오류 메시지의 내용은 바로 다음과 같다.
▶ 오류 메시지: importerror: cannot import name 'py3' from 'torch._six'
찾아보니, 최신 PyTorch에서는 존재하지 않는 모듈인 것으로 보인다.
다시 말해, PyTorch 버전이 달라서 발생하는 문제라고 보인다. 그래서 필자는 PyTorch 1.9.1 버전(version)을 사용하고 있는 상태에서 다음과 같이 PyTorch 1.8.1으로 변경했다.
pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
다만 아직도 오류 메시지가 존재했다.
그래서 1.8.1이 아니라, PyTorch 1.7.0 버전으로 한 번 더 다운그레이드 해보았다.
pip install torchmetrics==0.2.0
pip install torch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
결과적으로 문제가 해결되었다.
※ 참고 사항 ※
이전 PyTorch 버전을 설치하는 방법은 PyTorch 공식 문서에 잘 나와있다.
▶ PyTorch 공식 버전 확인: https://pytorch.org/get-started/previous-versions/
PyTorch
An open source machine learning framework that accelerates the path from research prototyping to production deployment.
pytorch.org