티스토리 뷰
[오류해결노하우]
[Pytorch] RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
따스한 개발자 2021. 10. 4. 21:25에러명 : RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
원인
- 입력 Tensor랑 너가 만든 모델(네트워크)가 각각 다른 곳에서 돌고 있다.
- 예를 들어 입력 Tensor는 CPU쪽 메모리에 있는데 모델(네트워크)은 GPU에서 돌고 있다...
- 상호 참조가 안되서 생기는 문제다.
해결방안
- 입력 Tensor를 GPU 메모리로 보내면 된다.
- 예를 들어 입력 Tensor의 변수명이 input_tensor라 하자
- 그럼 input_tensor를 Variable(input_tensor.cuda())로 바꾸면 깔끔하게 해결된다. (Variable을 쓰려면 from torch.autograd import Variable를 코드 맨 앞에 써야한다. )
'[오류해결노하우]' 카테고리의 다른 글
| [Raspberry pi 4] Green led(Act led) 안깜빡임 (0) | 2021.10.04 |
|---|---|
| [Notion] 사용 중 한글 입력 지연 현상 해결 방법 (0) | 2021.10.04 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- TQQQ
- 윈도우
- 주식일지
- 장기투자
- 해외주식
- Notion한글입력지연
- PYTHON
- weight type
- cuda
- Notion입력
- 적립식투자
- notion
- 마이크로소프트
- 수익실현
- 수익
- Notion한글입력
- input type
- MS
- 미국주식
- Notion입력지연
- 수익전환
- Microsoft
- Apple
- gpu
- 레버리지ETF
- RuntimError
- 애플
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함
