This commit is contained in:
Haoming 2026-02-02 11:28:08 +08:00
parent 9fc2e00b40
commit 82fa77ea0e
2 changed files with 16 additions and 0 deletions

View File

@ -1313,6 +1313,21 @@ def soft_empty_cache(force=False):
signal_empty_cache = False
def unload_model(model: "ModelPatcher") -> bool:
index = None
for i, p in enumerate(current_loaded_models):
if p.model == model:
index = i
break
if index is not None:
mdl = current_loaded_models.pop(index)
del mdl
return True
return False
def unload_all_models():
free_memory(1e30, get_torch_device())

View File

@ -344,6 +344,7 @@ class ControlNet(ControlBase):
def cleanup(self):
self.model_sampling_current = None
memory_management.unload_model(self.control_model_wrapped)
super().cleanup()