nadermx / backgroundremover

Background Remover lets you Remove Background from images and video using AI with a simple command line interface that is free and open source.
https://www.backgroundremoverai.com
MIT License
6.45k stars 535 forks source link

Performance issues with concurrent scripts #56

Closed sparkfield closed 11 months ago

sparkfield commented 1 year ago

I have a machine with Intel i9, 16 cores / 24 threads and 128GB RAM running Linux Debian 11. When I run the script like "/usr/local/bin/backgroundremover -i 1.png -m u2net -o 1_nb.png" everything works perfectly fine. It takes about 2.5 seconds in total and top shows that all 24 cpu's use about 10%, no problems at all.

However when I run the script concurrently 2 times: /usr/local/bin/backgroundremover -i 1.png -m u2net -o 1_nb.png & /usr/local/bin/backgroundremover -i 2.png -m u2net -o 2_nb.png &

This takes about 20 seconds to complete where top shows that all 24 cpu's use 100% constantly.

Running the script concurrently 3 times: /usr/local/bin/backgroundremover -i 1.png -m u2net -o 1_nb.png & /usr/local/bin/backgroundremover -i 2.png -m u2net -o 2_nb.png & /usr/local/bin/backgroundremover -i 3.png -m u2net -o 3_nb.png &

This takes about 45 seconds to complete with all cpu's using 100%.

Running any of them (1,png, 2.png, 3.png) individually takes just about 2.5 seconds.

Why is running the scripts concurrently so slow and more important, how can I fix this?

nadermx commented 11 months ago

I think this should be fixed as I took out the nices. Re open if not