Refactor memory cleaning into a single function

This commit is contained in:
Aarni Koskela
2024-01-16 14:47:44 +02:00
parent 2e4bee6f24
commit afc38707d5
15 changed files with 46 additions and 65 deletions

9
library/device_utils.py Normal file
View File

@@ -0,0 +1,9 @@
import gc
import torch
def clean_memory():
if torch.cuda.is_available():
torch.cuda.empty_cache()
gc.collect()