기술
파이토치 GPU 로 돌리기, pytorch gpu
기술 공간
2022. 8. 19. 16:35
참고용 링크 : https://towardsdatascience.com/pytorch-switching-to-the-gpu-a7c0b21e8a99
PyTorch: Switching to the GPU
How and Why to train models on the GPU — Code Included.
towardsdatascience.com
대강 읽어봤을때,
model 인스턴스에 (여기선 예를들어 model 인스턴스 이름이 net 임) net.to(device) 를 하고
train 또는 test 함수 내에서 dataloader 를 통해 inputs 와 labels 를 불러올때, 각각 inputs.to(device) labels.to(device) 를 해주면 되는 것 같다.