mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-23 13:00:54 +08:00
Update execution.py
This commit is contained in:
parent
74037f35db
commit
95acb06959
25
execution.py
25
execution.py
@ -731,6 +731,31 @@ class PromptExecutor:
|
||||
"outputs": ui_outputs,
|
||||
"meta": meta_outputs,
|
||||
}
|
||||
|
||||
try:
|
||||
import comfy.model_management as mm
|
||||
|
||||
# If ComfyUI exposes loaded text encoders (most builds do)
|
||||
if hasattr(mm, "loaded_text_encoders"):
|
||||
for enc in list(mm.loaded_text_encoders.values()):
|
||||
try:
|
||||
mm.unload_text_encoder(enc)
|
||||
except:
|
||||
pass
|
||||
|
||||
mm.loaded_text_encoders.clear()
|
||||
|
||||
# Final RAM + VRAM cleanup
|
||||
try:
|
||||
mm.cleanup_models_gc()
|
||||
except:
|
||||
pass
|
||||
|
||||
print("[RAM Optimizer] Text encoders unloaded successfully after run.")
|
||||
except Exception as e:
|
||||
print(f"[RAM Optimizer] Failed to unload text encoders: {e}")
|
||||
# --- END: Text Encoder RAM Cleanup Patch ---
|
||||
|
||||
self.server.last_node_id = None
|
||||
if comfy.model_management.DISABLE_SMART_MEMORY:
|
||||
comfy.model_management.unload_all_models()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user