mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-08 22:35:09 +00:00
Refactor memory cleaning into a single function
This commit is contained in:
9
library/device_utils.py
Normal file
9
library/device_utils.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import gc
|
||||
|
||||
import torch
|
||||
|
||||
|
||||
def clean_memory():
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.empty_cache()
|
||||
gc.collect()
|
||||
Reference in New Issue
Block a user