mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
589 stars 159 forks source link

Increase in memory usage as number of images increase #350

Closed sidkau12 closed 4 months ago

sidkau12 commented 5 months ago

I have a csv file of prompts (100 prompts) and for each prompt I want to generate 32 images. I am using text to image API. The memory keeps increasing and when I see the logs of main.py

image

My script has async await functions and I am doing garbage collector, etc. But I am still facing this issue.

When I type htop I see the memory% spiking to 99% after generating around 100 images

Is anyone else facing this issue?

sidkau12 commented 5 months ago

@mrhan1993 @konieshadow When I am running the main.py of Fooocus, and I am running a script that hits Fooocus API, looks like it is storing everything in memory. And because it is storing everything in the memory the server is getting killed. What do we do in such a case?

mrhan1993 commented 4 months ago

use --queue-history to limit history. Since the history queue is unlimited by default and holds the complete task object, this will include the input image as well as the generated image. The queues are kept in memory, so the memory footprint will gradually increase. Also, I recommend trying a version based on cus fork, https://github.com/mrhan1993/Fooocusapi