[Pytorch] GPU(CUDA) 사용

CUDA 사용법

if torch.cuda.is_available():
    device = torch.device("cuda")
		# 설정 Option 1
		x = torch.ones(5, device = device)
		# 설정 Option 2
		y = torch.ones(5)
		y = y.to(device)
		
		z = x + y
		
		# GPU에서 CPU로 변경
		z = z.to("cpu")




© 2020.12. by SungJae Yu

Powered by S.J Yu