ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

add model cache after loaded

Open efwfe opened this issue 1 year ago • 4 comments

Hello, I made a PR to cache model after loaded. save the model instance in memory, that's really will cost some memory here, but dont worry, it will check the memory free both cpu and gpu, and free the memory when it's necessary. And this is the update version of https://github.com/comfyanonymous/ComfyUI/pull/3545.

Here is a gif example to show it, and it's really amazing.

Fully tested on openart template workflows. -> https://openart.ai/workflows/templates

530pgpif

efwfe avatar May 30 '24 07:05 efwfe

looks great ! how to use it?

333caowei avatar Jul 17 '24 13:07 333caowei

looks great ! how to use it?

You can try with this repo repository https://github.com/efwfe/ComfyUI.git, The bigger the memory, the better performance. Thank you for wanting to use.

efwfe avatar Jul 22 '24 02:07 efwfe

Hi can you keep your fork up to date please? I want to test this.

Charuru avatar Aug 19 '24 12:08 Charuru

Hi can you keep your fork up to date please? I want to test this.

Welcome to test it. It has been updated. Hope to know your feedback. It is recommended to add --low-vram parameter to reduce the memory usage of sdxl models.

efwfe avatar Aug 20 '24 01:08 efwfe

Sorry for asking a silly question. I couldn't find the definition of the variable 'ckpt_path' in the function 'load_state_dict_guess_config' within the sd.py file, and PyCharm is reporting a compilation error: 'Unresolved reference 'ckpt_path''.

shawnL128Po avatar Aug 27 '24 05:08 shawnL128Po

Sorry for asking a silly question. I couldn't find the definition of the variable 'ckpt_path' in the function 'load_state_dict_guess_config' within the sd.py file, and PyCharm is reporting a compilation error: 'Unresolved reference 'ckpt_path''.

Sorry,that's my mistake, the latest version of comfyui remove the parameter of ckpt_path, I have updated the code, you can try it now.

Actually I'm ready to close this PR because it's not really helpful in most cases. So I closed this thanks you guys.

efwfe avatar Aug 27 '24 07:08 efwfe

I think it is very useful, I hope you can continue to update, thank you, cool

WSvisionG avatar Oct 07 '24 11:10 WSvisionG

Hi! Nice project and solution!

I see your workflow, do nothing but cache cpt. so if I want to use it, i just update your script into comfyui and start it, right?

Any other operations should do?

chen1yunan avatar Feb 26 '25 09:02 chen1yunan

@efwfe hi, I think it is very useful! Thank you for your great work! I want to know if it is still available now and if it supports caching for the Lora model?

dailingx avatar Mar 15 '25 13:03 dailingx