[Colab] RuntimeError: CUDA out of memory.
2021. 8. 16. 17:22
RuntimeError: CUDA out of memory. Tried to allocate 12.00 MiB (GPU 0; 7.43 GiB total capacity; 6.38 GiB already allocated; 8.81 MiB free; 6.69 GiB reserved in total by PyTorch)
batch size가 너무 크거나 코드 상에서 메모리가 불필요하게 사용되고 있기 때문에 발생.
아래와 같은 해결 방법들이 있다.
1. batch size 사이즈 줄이기
-> batch size 64에서 32로 조정
2. GPU의 캐시를 비워줌
import gc
gc.collect()
torch.cuda.empty_cache()
-> 여기서 해결됨 !
3. nvidia-smi 로 실행중인 프로세스 확인한 후 kill
'AI > 기타' 카테고리의 다른 글
딥러닝 공부하기 좋은 사이트 정리 (0) | 2021.07.23 |
---|