danielgatis / rembg

Rembg is a tool to remove images background
MIT License
15.39k stars 1.75k forks source link

[BUG] Not using GPU! #600

Closed FlashlightET closed 4 months ago

FlashlightET commented 4 months ago

Update: it seems like onnxruntime_gpu either wasnt installed or was installed alongside regular onnxruntime

Update 2: that fixed it

Describe the bug The library, despite being installed with [gpu,cli], refuses to run on GPU no matter what I try (including installing torch and importing that). It seems like every single issue about it ends up being closed by the github bot so that nobody sees it and it never gets solved.

To Reproduce Steps to reproduce the behavior:

1. run script

import torch
from rembg import remove
from PIL import Image
import os

for i in os.listdir('in'):
    input_path = 'in/'+i
    output_path = 'output.png'

    input = Image.open(input_path)
    output = remove(input)
    output.save(output_path)

2. ???

Expected behavior rembg runs on GPU instead of slow CPU

Images image

OS Version: Windows 11

Rembg version: v2.0.55

Additional context running in a separate 3.9 runtime with just the stuff from pip install rembg[gpu,cli] and installing torch