From afb11547d70568985ca3ee6352aa29630eea96ae Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 28 Jan 2026 07:52:52 +0000 Subject: [PATCH] add mm.unload model before loading --- nodes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nodes.py b/nodes.py index 6c3706b..269ef33 100644 --- a/nodes.py +++ b/nodes.py @@ -11,6 +11,9 @@ import torch from PIL import Image import numpy as np +import gc +from comfy import model_management as mm + class AnyComboList(list): """ A JSON-serializable list subtype used as a ComfyUI socket type. @@ -59,6 +62,14 @@ class RunningHub_ZImageI2L_Loader: # self.processor_path = os.path.join(folder_paths.models_dir, 'DiffSynth-Studio', 'Qwen-Image-Edit') def load(self): + + loaded_models = mm.current_loaded_models + print(f'[kiki] loaded_models:', len(loaded_models)) + if len(loaded_models) > 0: + mm.unload_all_models() + gc.collect() + torch.cuda.empty_cache() + pipe = ZImagePipeline.from_pretrained( torch_dtype=torch.bfloat16, device="cuda",