[Solved] CUDA ERROR

siwoo·2023년 12월 21일

오류해결

목록 보기
1/3

RuntimeError: CUDA error: an illegal instruction was encountered
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.

에러 메시지는 위와 같았다.

돌리려고 했던 .py 파일에

import os
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
os.environ["TORCH_USE_CUDA_DSA"] = '1'

세 줄 추가했다.

그리고

ps aux | grep python 명령어를 linux terminal에서 입력하면
작업중인 process id들을 확인할 수 있는데, 나 같은 경우에는 이전 프로세스가
메모리에 올려져 있어서 오류가 난 거였다.

그래서 kill -9 processid를 해주면 해당 프로세스를 완벽히 메모리에서도 제거할 수 있다.

참고로 process id는 ps aux | grep python을 했을 때
root 12345 0.0 ~
이런식으로 한 줄씩 뜰텐데 12345가 process id에 해당하는 값이다

이렇게 세팅해주고 kill을 주기적으로 해줬더니 실행이 잘 되었다.

0개의 댓글