Giter Site home page Giter Site logo

[FEATURE] Add --gpu 0 --gpu 1 about rembg HOT 4 CLOSED

zackees avatar zackees commented on September 18, 2024
[FEATURE] Add --gpu 0 --gpu 1

from rembg.

Comments (4)

zackees avatar zackees commented on September 18, 2024

For anyone else coming here for the exact same issue. Some interesting notes that I made while researching this:

The onyxruntime does not allow querying of active cards. You need to have pytorch or tensorflow, but this will only work if they have the very large GPU deps loaded (yuck). You can query otherwise with nvidia-smi.

You can manually set the GPU device via environmental variables

export CUDA_VISIBLE_DEVICES=0
export CUDA_VISIBLE_DEVICES=1

from rembg.

zackees avatar zackees commented on September 18, 2024

Okay, i was able to implement this in my front end with a --gpu-count 2

If anyone wants to check that out see removebackground cmdlet in https://github.com/zackees/zcmds

from rembg.

zackees avatar zackees commented on September 18, 2024

To close the loop on this, what was going on is that despite the install instructions, I could not get rembg to use the GPU on windows using the pipx install. I think it's possible to do an isolated environment and conditionally inject the needed torch files.

The work around for performance is to recognize that the CPU version of the executor does not seems to utilize threads effectively so you can actually get a lot more performance if you split up the number of files into separate folders and run the p tool on each, then merge back into one folder.

On my 12 CPU machine I was able to max out the performance at about 5 processes. Each process will report that it's running 4.5 seconds per iteration, so in AVERAGE that is under 1 second per image, so I consider that a massive win. The single threaded performance is about 2.8 seconds per image on my machine. So running parallel rembg p gave me a speedup of about 3x.

from rembg.

cmarshall108 avatar cmarshall108 commented on September 18, 2024

Is there support for metal acceleration (macs)?

from rembg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.