Chaoses-Ib / ComfyScript

A Python frontend and library for ComfyUI
https://discord.gg/arqJbtEg7w
MIT License
432 stars 24 forks source link

[Question] About lifecycle of models #11

Closed cian0 closed 9 months ago

cian0 commented 10 months ago

Hi I haven't tried it yet but genuinely interested, my question would be about the loaded model's lifecycles. In comfy whenever i switch workflows it will have to reload the models because they have different node IDs, just wondering if using this library would fix that if I were to create a repository of workflows..

Chaoses-Ib commented 10 months ago

Yes, you can control when to free the models. You should use with torch.inference_mode() instead of with Workflow() to avoid having similar behavior to ComfyUI.

By the way, I didn't find much docs about ComfyUI's model management, but it looks like it won't unload a model if only the node ID changed, instead, it's only unloaded if the reference count becomes zero.

Chaoses-Ib commented 9 months ago

See https://github.com/Chaoses-Ib/ComfyScript/issues/21#issuecomment-1936482022 for unloading models.

cian0 commented 9 months ago

Awesome thanks!