ComfyUI-InstantID icon indicating copy to clipboard operation
ComfyUI-InstantID copied to clipboard

16G VRam is still an error?

Open danzakuo opened this issue 1 year ago • 15 comments

My display card has 16G VRam, which should generate a 1280 image, but why do I still have this error? please help. 16Gvram

danzakuo avatar Jan 27 '24 07:01 danzakuo

I think this is a bug.

https://www.reddit.com/r/comfyui/comments/178jm0p/how_to_fix_this_please_help_me/

kubilaykilinc avatar Jan 27 '24 10:01 kubilaykilinc

I fund a solution. I am using sdxl turbo base models (for example Dreamshaper XL turbo, etc.) image

i am using 12-14 steps (max 14) [you can try another low steps) and GD Scale - 4 - 6 steps (5 is normal, max 6)

my VRAM 12 GB, i am using 14 steps, GD Scale 5

Immediately after creating an image I don't press the "Query Prompt" button. If I have a VRAM memory problem, I do not press this button immediately. I expect some auto-draining of VRAM. I find this custom node very useful. It allows monitoring VRAM. https://github.com/crystian/ComfyUI-Crystools

Additionally. If I want to intervene in the creation of the image (such as control pose) with Pose Image Optional. I make sure that the image I upload is not larger than standard SDXL image dimensions. Because I think larger images consume more VRAM.

kubilaykilinc avatar Jan 27 '24 21:01 kubilaykilinc

Thanks @kubilaykilinc. I am also using the RealVisXLTurbo model. Afterward, I can generate images successfully, but I still have errors sometimes and need to click the Query button once again, which is weird.

danzakuo avatar Jan 28 '24 06:01 danzakuo

A very successful project. I became a fan. But this vram problem really needs to be solved.

kubilaykilinc avatar Jan 28 '24 09:01 kubilaykilinc

A very successful project. I became a fan. But this vram problem really needs to be solved.

I guess it is not clear cache completely is the correct spelling of the word.. I hope someone solve this issue.

selamlar hocam bu arada :)

cerarslan avatar Jan 28 '24 10:01 cerarslan

A very successful project. I became a fan. But this vram problem really needs to be solved.

Unfortunately not much we can do until we get a more optimized version.

Xardous avatar Jan 29 '24 09:01 Xardous

guys, use the automatic1111 extension, I have a GEFORCE 3060 6GB VRAM, 32GB ram, amazing results, no OOM at all. You don't even have to check "low vram" setting in controlnet panels. With instantID under comfyui, I had random OOM's all the time, poor results since I can't get above 768*768.

here is a working automatic1111 setting for low VRAM system: automatic additionnal args: --lowvram --no-half-vae --xformers --medvram-sdxl

Positive prompt: In Casey Baugh's evocative style, art of a beautiful young girl cyborg with long brown hair, futuristic, scifi, intricate, elegant, highly detailed, majestic, Baugh's brushwork infuses the painting with a unique combination of realism and abstraction, greg rutkowski, surreal gold filigree, broken glass, (masterpiece, sidelighting, finely detailed beautiful eyes: 1.2), hdr, realistic painting, natural skin, textured skin, closed mouth, crystal eyes, butterfly filigree, chest armor, eye makeup, robot joints, long hair moved by the wind, window facing to another world, Baugh's distinctive style captures the essence of the girl's enigmatic nature, inviting viewers to explore the depths of her soul, award winning art Negative prompt: ugly, deformed, noisy, blurry, low contrast, text, BadDream, 3d, cgi, render, fake, anime, open mouth, big forehead, long neck Steps: 7, Sampler: DPM++ SDE Karras, CFG scale: 2, Seed: 924411214, Size: 768x1216, Model hash: 676f0d60c8, Model: dreamshaperXL_turboDpmppSDE, ControlNet 0: "Module: instant_id_face_embedding, Model: ip-adapter_instant_id_sdxl [eb2d3ec0], Weight: 1, Resize Mode: Crop and Resize, Low Vram: False, Processor Res: 512, Guidance Start: 0, Guidance End: 1, Pixel Perfect: False, Control Mode: Balanced, Hr Option: Both, Save Detected Map: True", ControlNet 1: "Module: instant_id_face_keypoints, Model: control_instant_id_sdxl [c5c25a50], Weight: 1, Resize Mode: Crop and Resize, Low Vram: False, Processor Res: 512, Guidance Start: 0, Guidance End: 1, Pixel Perfect: False, Control Mode: Balanced, Hr Option: Both, Save Detected Map: True", Pad conds: True, Version: v1.6.0 processing | 137.3/16.6s

Time taken: 3 min. 51.5 sec.

A: 5.88 GB, R: 10.52 GB, Sys: 6.0/6 GB (100.0%)

aminesoulaymani avatar Jan 29 '24 11:01 aminesoulaymani

I have a solution for memory optimisation. Actually, I have 2 levels. My hunch is that they are not entirely stable. Eg. you can't switch from one to another or disable them if not needed after a run. This needs extra work. I will try to share via a PR. I can run InstantID on my 4070 (12GB VRAM) many times.

Level 1 This is a faster solution. It uses enable_model_cpu_offload() VRAM usage during calculation: 85-88% Speed: 1.25 it/s Pros: relatively fast Cons: after 5-8 runs, OOM error is thrown, so need extra work to prevent memory leaking or better caching. A more clever dev can figure this out, I am sure.

Level 2 This is a slower solution. It uses enable_sequential_cpu_offload() VRAM usage during calculation:15-17% Speed: 2.35 s/it (2-3x slower) Pros: I can run this multiple times without any issues. Cons: Still, need VRAM to load the models, for this needs around 10 GB.

Please note that these are hack-ish solutions as these functions shouldn't be called more than once on a pipe, AFAIK. So, I had to add extra checking to detect if they were called (enable_sequential_cpu_offload()) or if possible, revert its effect (enable_model_cpu_offload()).

hortom avatar Feb 03 '24 14:02 hortom

PR is here: https://github.com/ZHO-ZHO-ZHO/ComfyUI-InstantID/pull/87

hortom avatar Feb 03 '24 15:02 hortom

idd0 iid

if you have 16g vram: Edit the file ComfyUI/custom_nodes/ComfyUI-InstantID/InstantIDNode.py

PS : This is a temporary solution. you can upscale it ( i use fooocus)

Screenshot from 2024-02-09 19-06-03

ComfyUI_00012_

ComfyUI_00012_u

ComfyUI_00013_ ComfyUI_00013_u

ComfyUI_00014_ ComfyUI_00014_u

Here are the original images:

ComfyUI_00015_

ComfyUI_00016_ ComfyUI_00017_ ComfyUI_00018_ ComfyUI_00019_ ComfyUI_00020_

lorb888 avatar Feb 08 '24 09:02 lorb888

idd0 iid

if you have 16g vram: Edit the file ComfyUI/custom_nodes/ComfyUI-InstantID/InstantIDNode.py

Thank you. Now I can run 900x900(896x896) with 12gb gpu.

cerarslan avatar Feb 08 '24 23:02 cerarslan

idd0 iid if you have 16g vram: Edit the file ComfyUI/custom_nodes/ComfyUI-InstantID/InstantIDNode.py

Thank you. Now I can run 900x900(896x896) with 12gb gpu.

So, we "only" need a size settings? How about the quality?

hortom avatar Feb 09 '24 08:02 hortom

idd0 iid if you have 16g vram: Edit the file ComfyUI/custom_nodes/ComfyUI-InstantID/InstantIDNode.py

Thank you. Now I can run 900x900(896x896) with 12gb gpu.

So, we "only" need a size settings? How about the quality?

Not quiet good actually. :) but I just wanna try

cerarslan avatar Feb 09 '24 08:02 cerarslan

https://github.com/InstantID/InstantID/issues/135#issue-2127529858 for less vram ill try it

al-swaiti avatar Feb 09 '24 20:02 al-swaiti

guys, use the automatic1111 extension, I have a GEFORCE 3060 6GB VRAM, 32GB ram, amazing results, no OOM at all. You don't even have to check "low vram" setting in controlnet panels. With instantID under comfyui, I had random OOM's all the time, poor results since I can't get above 768*768.

here is a working automatic1111 setting for low VRAM system: automatic additionnal args: --lowvram --no-half-vae --xformers --medvram-sdxl

Positive prompt: In Casey Baugh's evocative style, art of a beautiful young girl cyborg with long brown hair, futuristic, scifi, intricate, elegant, highly detailed, majestic, Baugh's brushwork infuses the painting with a unique combination of realism and abstraction, greg rutkowski, surreal gold filigree, broken glass, (masterpiece, sidelighting, finely detailed beautiful eyes: 1.2), hdr, realistic painting, natural skin, textured skin, closed mouth, crystal eyes, butterfly filigree, chest armor, eye makeup, robot joints, long hair moved by the wind, window facing to another world, Baugh's distinctive style captures the essence of the girl's enigmatic nature, inviting viewers to explore the depths of her soul, award winning art Negative prompt: ugly, deformed, noisy, blurry, low contrast, text, BadDream, 3d, cgi, render, fake, anime, open mouth, big forehead, long neck Steps: 7, Sampler: DPM++ SDE Karras, CFG scale: 2, Seed: 924411214, Size: 768x1216, Model hash: 676f0d60c8, Model: dreamshaperXL_turboDpmppSDE, ControlNet 0: "Module: instant_id_face_embedding, Model: ip-adapter_instant_id_sdxl [eb2d3ec0], Weight: 1, Resize Mode: Crop and Resize, Low Vram: False, Processor Res: 512, Guidance Start: 0, Guidance End: 1, Pixel Perfect: False, Control Mode: Balanced, Hr Option: Both, Save Detected Map: True", ControlNet 1: "Module: instant_id_face_keypoints, Model: control_instant_id_sdxl [c5c25a50], Weight: 1, Resize Mode: Crop and Resize, Low Vram: False, Processor Res: 512, Guidance Start: 0, Guidance End: 1, Pixel Perfect: False, Control Mode: Balanced, Hr Option: Both, Save Detected Map: True", Pad conds: True, Version: v1.6.0 processing | 137.3/16.6s

Time taken: 3 min. 51.5 sec.

A: 5.88 GB, R: 10.52 GB, Sys: 6.0/6 GB (100.0%)

Hi my Friend, how is your picture looks like when you are using SD WEBUI InstantID

I got bad result, blured, low quality, althrough it succeed to replace face, but looks like ugly...

Would you like to post your picture ? Lots of thanks!!

tiwentichat avatar Feb 18 '24 18:02 tiwentichat