mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-20 03:13:30 +00:00
Code cleanups.
This commit is contained in:
parent
51dde87e97
commit
30eb92c3cb
@ -302,16 +302,15 @@ def unload_model_clones(model):
|
|||||||
def free_memory(memory_required, device, keep_loaded=[]):
|
def free_memory(memory_required, device, keep_loaded=[]):
|
||||||
unloaded_model = False
|
unloaded_model = False
|
||||||
for i in range(len(current_loaded_models) -1, -1, -1):
|
for i in range(len(current_loaded_models) -1, -1, -1):
|
||||||
if DISABLE_SMART_MEMORY:
|
if not DISABLE_SMART_MEMORY:
|
||||||
current_free_mem = 0
|
if get_free_memory(device) > memory_required:
|
||||||
else:
|
|
||||||
current_free_mem = get_free_memory(device)
|
|
||||||
if current_free_mem > memory_required:
|
|
||||||
break
|
break
|
||||||
shift_model = current_loaded_models[i]
|
shift_model = current_loaded_models[i]
|
||||||
if shift_model.device == device:
|
if shift_model.device == device:
|
||||||
if shift_model not in keep_loaded:
|
if shift_model not in keep_loaded:
|
||||||
current_loaded_models.pop(i).model_unload()
|
m = current_loaded_models.pop(i)
|
||||||
|
m.model_unload()
|
||||||
|
del m
|
||||||
unloaded_model = True
|
unloaded_model = True
|
||||||
|
|
||||||
if unloaded_model:
|
if unloaded_model:
|
||||||
|
Loading…
Reference in New Issue
Block a user