심드렁하게 저장

Error Fix List 본문

AI Project

Error Fix List

Ggoosae 2025. 3. 31. 10:33
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

이 에러는 GPU에서 수행 중인 연산에서 잘못된 인덱스/값이 들어가서 assert가 실패했을 때 발생 

 대표적인 원인

  1. 잘못된 라벨 인덱스
    • 예: CrossEntropyLoss 사용 중인데 target 값이 클래스 개수 이상 (>= num_classes)일 때
  2. 음수 인덱스
    • 예: label = -1이거나 None 상태로 학습에 들어가는 경우
  3. Tensor 크기 불일치
    • 예: input.shape = [B, 101], target = 101 (정수값이 클래스 개수보다 큼)