mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-20 03:23:00 +08:00
mm: make garbage collector null safe on real_model
currently this hard assumes that the caller of model_unload will keep current_loaded_models in sync. With RAMPressureCache its possible to have the garbage collector occur in the middle of the model free process which can split these two steps.
This commit is contained in:
parent
4a83a9bc0e
commit
7af5bf49e4
@ -557,7 +557,7 @@ class LoadedModel:
|
|||||||
self._patcher_finalizer.detach()
|
self._patcher_finalizer.detach()
|
||||||
|
|
||||||
def is_dead(self):
|
def is_dead(self):
|
||||||
return self.real_model() is not None and self.model is None
|
return self.real_model is not None and self.real_model() is not None and self.model is None
|
||||||
|
|
||||||
|
|
||||||
def use_more_memory(extra_memory, loaded_models, device):
|
def use_more_memory(extra_memory, loaded_models, device):
|
||||||
@ -753,7 +753,7 @@ def cleanup_models_gc():
|
|||||||
def cleanup_models():
|
def cleanup_models():
|
||||||
to_delete = []
|
to_delete = []
|
||||||
for i in range(len(current_loaded_models)):
|
for i in range(len(current_loaded_models)):
|
||||||
if current_loaded_models[i].real_model() is None:
|
if current_loaded_models[i].real_model is None or current_loaded_models[i].real_model() is None:
|
||||||
to_delete = [i] + to_delete
|
to_delete = [i] + to_delete
|
||||||
|
|
||||||
for i in to_delete:
|
for i in to_delete:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user