lquesada / ComfyUI-Inpaint-CropAndStitch

ComfyUI nodes to crop before sampling and stitch back after sampling that speed up inpainting
GNU General Public License v3.0
398 stars 23 forks source link

ComfyUI crashes on Inpaint Crop node #32

Closed Shyryp closed 3 months ago

Shyryp commented 3 months ago

The problem appears when I start using "Inpaint Crop" in the new ComfyUI functionality - loops from @guill.

After about 20-30 loops inside ForLoop, the program crashes on your "Inpaint Crop" node, without any error. I have no idea yet why exactly this could happen, I can't catch the error.

Here is an example of a workflow. You can run it yourself and check if ComfyUI will crash. LoopTest.json

I used your nodes on the latest version of ComfyUI.

For loops, I used this package (from the same author (@guill) who implemented Execution Model Inversion in ComfyUI a week ago): https://github.com/BadCafeCode/execution-inversion-demo-comfyui

@guill , you can also look at this workflow if you are interested in this problem with loops.

Why do I even assume that the problem is with Inpaint Crop - it's just that ComfyUI crashes on Inpaint Crop, as shown in this image:

error
lquesada commented 3 months ago

Hi, this sounds like you're running out of memory. Inpaint crop takes 3x-4x more memory per image because it creates a thick margin up to 0.5x per side to ensure that any aspect ratio you specify can be fit in the image.

This would mean 4x more memory per image.

I am surprised that this would crash comfyui though.

Are you using a mac? How much shared RAM? This could explain it if you were very tight in memory already and the images are very large (which the crop node enables you to process).

Can you monitor your ram while you run this (e.g. with low steps for it to be faster) and let me know if comfyui is incrementally using more RAM per loop run? If that is the case, it is very likely an issue in the way comfyui manages memory, it probably tries to keep every intermediate result in RAM for the current job in the queue, and that could be improved from comfyui side to allow running very long jobs (e.g. using for loop).

On Sun, Aug 25, 2024, 02:04 Alexander Priyomko @.***> wrote:

The problem appears when I start using "Inpaint Crop" in the new ComfyUI functionality - loops from @.*** https://github.com/guill]( https://github.com/guill.

After about 20-30 loops inside ForLoop, the program crashes on your "Inpaint Crop" node, without any error. I have no idea yet why exactly this could happen, I can't catch the error.

Here is an example of a workflow. You can run it yourself and check if ComfyUI will crash. LoopTest.json https://github.com/user-attachments/files/16738387/LoopTest.json

I used your nodes on the latest version of ComfyUI.

For loops, I used this package (from the same author @.*** https://github.com/guill) who implemented Execution Model Inversion in ComfyUI a week ago): https://github.com/BadCafeCode/execution-inversion-demo-comfyui

@.*** https://github.com/guill](https://github.com/guill , you can also look at this workflow if you are interested in this problem with loops.

Why do I even assume that the problem is with Inpaint Crop - it's just that ComfyUI crashes on Inpaint Crop, as shown in this image: error.PNG (view on web) https://github.com/user-attachments/assets/fff8789f-870f-440c-9010-dc7b63cb09a2

— Reply to this email directly, view it on GitHub https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch/issues/32, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCKTXOIKNZAIOSQZ6RLWQDZTENQXAVCNFSM6AAAAABNCACPK6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ4DIOJUGAYDKMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Shyryp commented 3 months ago

Yes, there is a memory overflow. Each cycle in ForLoop leaves an image in memory.

I am using ComfyUI on Windows 10.

But please make sure that your Inpaint Crop node does not affect new cycles and this memory overflow issue.

I will report the memory overflow to guill @

lquesada commented 3 months ago

it cannot be the crop node - it doesn't store anything :)

keep me posted with updates to the fix!

lquesada commented 3 months ago

From ComfyUI release notes:

Issue News:

[RAM] The issue of rapidly increasing memory usage due to models not being properly released from memory has been fixed.