Gourieff / comfyui-reactor-node

Fast and Simple Face Swap Extension Node for ComfyUI
GNU General Public License v3.0
1.57k stars 155 forks source link

memory issue #180

Open bihailantian655 opened 10 months ago

bihailantian655 commented 10 months ago

First, confirm

What happened?

during Restoring with GFPGANv1.4.pth the following error occured

numpy.core._exceptions._ArrayMemoryError: Unable to allocate 11.3 GiB for an array with shape (480, 768, 1368, 3) and data type float64

here is the workflow , but the total frame is 480.

if i set the total frame smaller , for exmple 100 no error will occure

Steps to reproduce the problem

r

r {0D524246-724B-46ae-A706-00A4CF3B6C3C}

Sysinfo

win11 rtx2080 8g vram, 32g ram

Relevant console log

[ReActor] 00:41:15 - STATUS - Using Hashed Source Face(s) Model...
[ReActor] 00:41:15 - STATUS - Analyzing Target Image...
[ReActor] 00:41:17 - STATUS - Swapping...
[ReActor] 00:41:17 - STATUS - --Done!--
[ReActor] 00:41:27 - STATUS - Restoring with GFPGANv1.4.pth
ERROR:root:!!! Exception during processing !!!
ERROR:root:Traceback (most recent call last):
  File "H:\ComfyUI\ComfyUI\execution.py", line 154, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
  File "H:\ComfyUI\ComfyUI\execution.py", line 84, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
  File "H:\ComfyUI\ComfyUI\execution.py", line 77, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
  File "H:\ComfyUI\ComfyUI\custom_nodes\comfyui-reactor-node\nodes.py", line 169, in execute
    out_images = np.ndarray(shape=image_np.shape)
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 11.3 GiB for an array with shape (480, 768, 1368, 3) and data type float64

Additional information

No response

bihailantian655 commented 10 months ago

{4D5247C0-D233-4ec9-B13E-1D7F2C66D56A}

Musigreg commented 7 months ago

I got the same issue yesterday.

The frames were extracted from the video, then the upscale went fine, the face swap went fine, and at the end, just before the interpolation node, error saying it cannot allocate 24Gb, with the same message as above.

It was a small video, so I succeeded by unloaded everything, restarting ComfyUI and launching directly from the Faceswap and it finished successfully.

Soondols commented 5 months ago

I just got the same issue! Did you fix it?

Gourieff commented 5 months ago

You should increase Virtual Memory in your OS

I have 64Gb of RAM and 16384Mb of Virtual Memory and never faced this error while processing any videos

Gourieff commented 5 months ago

You guys can try Evolve branch to check whether this issue is fixed or not

DonBaronFactory commented 4 months ago

The whole script has such a bad memory management, loads too much into RAM instead of using the performance of e.g. SSD storage or even the proper use of GPU.

I gave up with reactor and wrote our own script. With a 4060 / 16GB and 16GB Ram, we run 4 simultaneous swapping threads, each at 2.5 Frames per second (with restoration and masking) and have a 85% utilization of the GPU and 40% CPU. Besides that there is no limitation for durations of videos anymore because of no RAM issues ...

Time is of essence here, reactor is simply much too slow

Gourieff commented 4 months ago

The whole script has such a bad memory management, loads too much into RAM instead of using the performance of e.g. SSD storage or even the proper use of GPU.

I gave up with reactor and wrote our own script. With a 4060 / 16GB and 16GB Ram, we run 4 simultaneous swapping threads, each at 2.5 Frames per second (with restoration and masking) and have a 85% utilization of the GPU and 40% CPU. Besides that there is no limitation for durations of videos anymore because of no RAM issues ...

Time is of essence here, reactor is simply much too slow

You can make a PR and improve ReActor instead of complaining, it's an opensource non-commercial app that is still in development stage. Me and the other guys (to whom I am very grateful) develops ReActor in our free time

richadlee commented 2 days ago

The whole script has such a bad memory management, loads too much into RAM instead of using the performance of e.g. SSD storage or even the proper use of GPU.

I gave up with reactor and wrote our own script. With a 4060 / 16GB and 16GB Ram, we run 4 simultaneous swapping threads, each at 2.5 Frames per second (with restoration and masking) and have a 85% utilization of the GPU and 40% CPU. Besides that there is no limitation for durations of videos anymore because of no RAM issues ...

Time is of essence here, reactor is simply much too slow

Same issue, can you share your script?