MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / free_memory

Function free_memory

diffusers/src/diffusers/training_utils.py:263–272  ·  view source on GitHub ↗

Runs garbage collection. Then clears the cache of the available accelerator.

()

Source from the content-addressed store, hash-verified

261
262
263def free_memory():
264 """Runs garbage collection. Then clears the cache of the available accelerator."""
265 gc.collect()
266
267 if torch.cuda.is_available():
268 torch.cuda.empty_cache()
269 elif torch.backends.mps.is_available():
270 torch.mps.empty_cache()
271 elif is_torch_npu_available():
272 torch_npu.empty_cache()
273
274
275# Adapted from torch-ema https://github.com/fadel/pytorch_ema/blob/master/torch_ema/ema.py#L14

Callers 8

mainFunction · 0.90
log_validationFunction · 0.90
mainFunction · 0.90
log_validationFunction · 0.90
mainFunction · 0.90
log_validationFunction · 0.90
mainFunction · 0.90
log_validationFunction · 0.90

Calls 1

is_torch_npu_availableFunction · 0.85

Tested by

no test coverage detected