✅ 에러 내용
BERT 모델을 돌리는데, 아래와 같은 에러가 발생하였다.
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.

✅ 해결 방법
이것저것 찾아보니, 레이블 인코딩이나 텐서 크기 불일치 때문에 일어난 문제 같았다.
즉, 입출력 차원이 맞지 않아서 발생한 문제!
아래 코드로 고유 레이블 개수로 num_labels가 몇 개인지 본 다음 이 숫자로 설정하여, 모델 초기화 시 명시해줬더니 해결됐다.
num_labels = ae_df['PT_encoded'].nunique()
print(f"Number of unique labels: {num_labels}")
만약 num_labels가 100개라면, BertForSequenceClassification을 사용할 때 num_labels=100으로 설정하여 모델을 다시 로드한 것이다.
'기타 > Error' 카테고리의 다른 글
[Unsolved] BeautifulSoup를 사용한 CDISC SDTM 스크래핑 (0) | 2025.01.07 |
---|
✅ 에러 내용
BERT 모델을 돌리는데, 아래와 같은 에러가 발생하였다.
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.

✅ 해결 방법
이것저것 찾아보니, 레이블 인코딩이나 텐서 크기 불일치 때문에 일어난 문제 같았다.
즉, 입출력 차원이 맞지 않아서 발생한 문제!
아래 코드로 고유 레이블 개수로 num_labels가 몇 개인지 본 다음 이 숫자로 설정하여, 모델 초기화 시 명시해줬더니 해결됐다.
num_labels = ae_df['PT_encoded'].nunique()
print(f"Number of unique labels: {num_labels}")
만약 num_labels가 100개라면, BertForSequenceClassification을 사용할 때 num_labels=100으로 설정하여 모델을 다시 로드한 것이다.
'기타 > Error' 카테고리의 다른 글
[Unsolved] BeautifulSoup를 사용한 CDISC SDTM 스크래핑 (0) | 2025.01.07 |
---|