1. PyTorch 설치를 위해 Anaconda에 새로운 가상환경("pytorch")을 생성하고 활성화시킨다
2. PyTorch 홈페이지에서 설치할 버전을 선택하여 설치 명령어를 찾는다. GPU 가속을 사용하기 위해 CUDA 10.2 버전으로 선택한다.
https://pytorch.org/get-started/locally/
PyTorch
An open source deep learning platform that provides a seamless path from research prototyping to production deployment.
pytorch.org
아래 NVIDIA 홈페이지에서 CUDA도 찾아서 설치한다
https://developer.nvidia.com/cuda-10.2-download-archive
CUDA Toolkit 10.2 Download
Select Target Platform Click on the green buttons that describe your target platform. Only supported platforms will be shown. Operating System Architecture Distribution Version Installer Type Do you want to cross-compile? Yes No Select Host Platform Click
developer.nvidia.com
3. 활성화된 가상환경에서 conda 명령어를 입력하여 PyTorch 설치
4. 주피터 노트북을 실행하고 PyTorch가 설치된 가상환경 커널로 선택하여 빈 노트를 작성한다.
PyToch를 import 한다. cuda가 정상적으로 사용가능한지 확인해본다.
import torch
torch.cuda.is_available()
변수를 생성해서 GPU로 보내본다.
x = torch.randn(5).to("cuda:0")
print(x)
주피터 노트북에서 파이토치 설치가 끝났다
'PyTorch' 카테고리의 다른 글
[PyTorch] Focal Loss (0) | 2021.04.22 |
---|---|
[PyTorch] nn.LSTM input, output shape (0) | 2020.06.30 |
[PyTorch] Training 헬퍼 함수 만들기 (0) | 2020.06.17 |
[PyTorch] last fully connected layer에 regularization 추가하기 (0) | 2020.06.17 |