반응형
문제
GPU 상의 cache를 정리해주기 위해 torch.cuda.empty_cache() 사용 시 에러
torch.cuda.empty_cache()
>> RuntimeError: CUDA error: out of memoryCUDA 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.
해결
with torch.cuda.device('cuda:0'):
torch.cuda.empty_cache()
참고
Out of memory when I use torch.cuda.empty_cache - PyTorch Forums
반응형