Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- __call__
- 컴퓨터비전
- torch.nn
- AI
- pytorch
- rnn
- vision transformer
- objectdetection
- segmentation
- python
- LSTM
- Deep learning
- 가상환경구축
- 딥러닝
- 파이썬문법
- 가상환경
- torch
- DeepLearning
- Anaconda
- NumPy
- vsC
- tensorflow
- torch.nn.Module
- ViT
- Torchvision
- CNN
- __init__
- pychram
- 머신러닝
- 파이썬
Archives
- Today
- Total
인공지능을 좋아하는 곧미남
gpu에 할당된 tensor데이터를 numpy array로 변환할때 cpu 연산으로 변환한 뒤 실시 본문
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
input.float().to(device)
np.array(input[i].permute(1, 2, 0).cpu(), dtype=np.float32)
이때 input에 .cpu()로 cpu연산 변환이 되지 않으면, 아래 Error가 발생함.
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
'code_study > pytorch' 카테고리의 다른 글
[torchvision] ImageFolder (0) | 2022.05.16 |
---|---|
pytorch의 def forward(self, x) (0) | 2022.01.18 |
BackBone Encoder Layer에서 Feature Map 추출 (0) | 2022.01.17 |
torch.nn.Sequential (0) | 2022.01.14 |
pytorch DataLoader (0) | 2022.01.10 |
Comments