MCPcopy
hub / github.com/kohya-ss/sd-scripts / clean_memory

Function clean_memory

library/device_utils.py:32–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30
31
32def clean_memory():
33 gc.collect()
34 if HAS_CUDA:
35 torch.cuda.empty_cache()
36 if HAS_XPU:
37 torch.xpu.empty_cache()
38 if HAS_MPS:
39 torch.mps.empty_cache()
40
41
42def clean_memory_on_device(device: Optional[Union[str, torch.device]]):

Callers 2

__call__Method · 0.90
__call__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected