RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x1 and 1024x100), RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x1 and 1024x100)
RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR
RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling cublasCreate(handle)
../aten/src/ATen/native/cuda/Loss.cu:240: nll_loss_forward_reduce_cuda_kernel_2d: block: [0,0,0], thread: [0,0,0] Assertion t >= 0 && t < n_classes
failed.
RuntimeError: mat1 and mat2 must have the same dtype
RuntimeError: both arguments to matmul need to be at least 1D, but they are 0D and 2D
=> 모든 코드가 다 잘 돌아가고 trainer.fit(model, data_module)까지 잘되어서 마지막으로 test에 적용만 시키면 되는 상황이었는데 에러가 떴다
뜬 에러는, trainer.test(model, datamodule=data_module) 여기에서 생겼고
왜 형태가 다른거지? print 를 여러가지 방향으로 고민했다
에러가 뜬다는 코드를 가서 print를 직접 시켜보니 534번까지 torch.Size([4, 128]), torch.Size([4])가 나왔었는데 마지막에 갑자기 torch.Size([]), torch.Size([1, 128])가 나오며 에러가 뜬다.
torch.Size([4, 128])
Testing DataLoader 0: 99%|██████████████████████████████████████████████████████████▋| 532/535 [00:04<00:00, 115.74it/s]torch.Size([4])
====
torch.Size([4, 128])
torch.Size([4])
====
torch.Size([4, 128])
torch.Size([4])
====
torch.Size([4, 128])
torch.Size([4])
====
torch.Size([4, 128])
Testing DataLoader 0: 100%|██████████████████████████████████████████████████████████▊| 533/535 [00:04<00:00, 115.75it/s]torch.Size([4])
====
torch.Size([4, 128])
torch.Size([4])
====
torch.Size([4, 128])
torch.Size([4])
====
torch.Size([4, 128])
torch.Size([4])
====
torch.Size([4, 128])
Testing DataLoader 0: 100%|██████████████████████████████████████████████████████████▉| 534/535 [00:04<00:00, 115.77it/s]
torch.Size([])
====
torch.Size([1, 128])
이 값만 없애버린다면? 에러가 안뜰것이다 => 해결책은, 마지막 배치를 무시하는 것으로
DataLoader를 설정할 때 drop_last=True를 설정하는 것이다
test_dataloader = DataLoader(test_set, batch_size=batch_size, drop_last=True)
=> 이를 통해 에러 해결!
위 에러는 다른 경우에도 많이 나오는데 나는 이런 이유로 에러가 떴었었다..
if __name__ == '__main__':
from mmengine.runner import Runner
모든 코드들을 여기 다음에 이어서 넣어준다
RuntimeError: Error(s) in loading state_dict for DataParallel:
Missing key(s) in state_dict: "module.trans.in_block.0.weight".....
```
python
directory = f'./result/{which_data}/{sampling}/{n_clf}/'
if not os.path.exists(directory):
os.makedirs(directory)
df_result.to_csv(directory+f'STATENet_30_{fold}_f.csv')
```
for user_feats in batch:
# 여기 계속 에러 떠서 수정
user_feats["input_ids"] = torch.stack([user_feats["input_ids"]] * len(batch), dim=0)
user_feats["attention_mask"] = torch.stack([user_feats["attention_mask"]] * len(batch), dim=0)
user_feats["token_type_ids"] = torch.stack([user_feats["token_type_ids"]] * len(batch), dim=0)
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1" # Gpu 번호 설정 !!!!
os.environ["TOKENIZERS_PARALLELISM"] = "false"