본문 바로가기
Programming Language/Python

[Pytorch] "RuntimeError: CUDA error: an illegal memory access was encountered" 에러 발생 시

by yongee97 2023. 12. 12.

* 에러

파이토치에서 텐서를 gpu로 옮겨주는 과정인 .to(device)를 실행하면 아래와 같은 에러 발생

에러 화면

 

에러가 어디서 발생했는지 확인하기 위해, 다음 환경변수를 설정

CUDA_LAUNCH_BLOCKING=1

 

* 해결 방법

 

터미널에 다음 명령어 입력

export TORCH_CUDNN_V8_API_DISABLED=1

 

 

* Reference

https://github.com/pytorch/pytorch/issues/99372

 

PyTorch 2.0.0 encountered CUDA error: an illegal memory access was encountered · Issue #99372 · pytorch/pytorch

🐛 Describe the bug Running PyTorch 2.0.0 encountered CUDA error: an illegal memory access was encountered. We wrote a benchmark tool to use pytorch to run inference (See the commands below on how t...

github.com