냥냥파워

RuntimeError: CUDA error: device-side assert triggered 본문

POSTECH AI연구원 인턴

RuntimeError: CUDA error: device-side assert triggered

hjhjhj0028 2022. 6. 16. 14:28

https://brstar96.github.io/shoveling/device_error_summary/

 

이유를 알 수 없는 GPU 에러 정리(device-side assert, CUDA error, CUDNN_STATUS_NOT_INITIALIZED 등등…)

 

brstar96.github.io

https://towardsdatascience.com/cuda-error-device-side-assert-triggered-c6ae1c8fa4c3

 

CUDA error: Device-side assert triggered

A beginner friendly solution walkthrough for this frustrating (and common) error in Pytorch

towardsdatascience.com

GPU 작업을 하다보면

정말 알 수 없는 cuda 에러가 뜰 때가 있다

 

가장 기본적으로 체크해야 하는건

 

1. 모델 input output size가 dataset과 맞는지

 

2. 모델 input으로 들어가는 data class num이 0부터 시작하는지

 

이게 무슨 소리냐면

github issues를 보니까

제일 많은 따봉을 받은 선생님께서 말씀하시길,

Another common reason for this error could be if the number of classes in the labels does not match with the number of units in the final softmaxed Linear Layer for a classification problem. I recently encountered this accidentally.

즉 input class num이랑 model 연산 후 output class num이 

같아야 제대로 구동한다는 것이다

 

3. cuda와 cudnn등 환경 구축을 제대로 했는지(버전 호환 문제 등)

 

보통 이 3가지면 해결이 되는데

(nvidia -smi랑 torch.cuda.is_available() is True가 될 때)

 

그래도 안된다면 무한 구글링과 디버깅이 답이다!

device를 cuda말고 cpu로 돌려보는 것도 방법..

BIG