반응형

에러 메시지:

/opt/conda/conda-bld/pytorch_1682343995026/work/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.

 

에러 메시지 해석:

loss를 계산하는 과정에서 label(ground_truth)output(predict_truth)클래스 숫자가 예상 밖인 0~n_classes-1 이외의 숫자로 나올 경우 해당 오류가 발생한다. 

 

해결:

필자의 경우 사용하는 데이터셋 중 라벨이 없는 데이터셋이 있는데, 해당 데이터셋을 사용하여 label 부분을 print 한 결과 잘못된 label이 -1로 전부 나와 해당 오류를 확인했다. 따라서, 적절한 데이터셋으로 바꿔 다시 코드를 실행했고, 적절한 label을 얻어 해당 오류가 해결되었다.

반응형
반응형

버전 확인

파이썬 버전을 확인할 수 있습니다.

!python --version

파이썬 버전 설치 

!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1

파이썬 버전 선택 

!sudo update-alternatives --config python3

enter키로 현재 버전(*)을 선택하거나 selection number를 입력하여 선택할 수 있다.


파이썬 pip 설치

!sudo apt install python3-pip

 

 

참고 사이트

 

How to Change Python Version in Google Colab : 3 Steps Only

Sometimes a specific version of python is required to work for the python modules. Know How to Change Python Version in Google Colab in steps

www.datasciencelearner.com

 

반응형

+ Recent posts