mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-07-21 21:01:24 +08:00
unload
This commit is contained in:
parent
9fc2e00b40
commit
82fa77ea0e
@ -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())
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user