backgroundremover
backgroundremover copied to clipboard
Performance issues with concurrent scripts
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?