인프런 커뮤니티 질문&답변
파이토치 device (gpu / cpu) 관련 질문드립니다.
작성
·
675
답변 1
0
YoungJea Oh
지식공유자
device를 지정해 주지 않고 만들면 CPU tensor가 되고 device를 "cuda:0"로 지정해 주고 만들면 GPU tensor가 됩니다.
x = torch.tensor([[1, 2, 3], [4, 5, 6]], dtype=torch.int32)
x --> cpu tensor
x = torch.tensor([[1, 2, 3], [4, 5, 6]], dtype=torch.int32, device="cuda:0")
x --> gpu tensordocument에 다음과 같이 설명이 되어 있습니다.
torch.tensor(data, *, dtype=None, device=None, requires_grad=False, pin_memory=False)
device (
torch.device, optional) – the device of the constructed tensor. If None and data is a tensor then the device of data is used. If None and data is not a tensor then the result tensor is constructed on the CPU.
더 자세한 사항은 https://pytorch.org/docs/stable/generated/torch.tensor.html 문서를 참조하세요. 좋은 질문 감사 드립니다.






감사합니다.