plemeri / transparent-background

This is a background removing tool powered by InSPyReNet (ACCV 2022)
MIT License
791 stars 87 forks source link

Is there an option to run on gpu instead of cpu? #46

Closed ttyksi closed 10 months ago

ttyksi commented 10 months ago

As the title says, is there an option somewhere to use gpu instead of cpu? I am using an RTX3070 and would be happy to see it run faster, am I missing something?

plemeri commented 10 months ago

It will automatically use gpu if available. Please verify your pytorch installation first.

Python 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
>>>
ttyksi commented 10 months ago

I installed Python 3.11.5 and pytorch 1.7.1, but the situation did not change. I don't know what it is, but I am sure it is due to an inherent problem in my environmentπŸ˜“ I am using drag and drop images into a bat with the description "transparent-background --source %1 --type white", is there a problem with this usage?

plemeri commented 10 months ago

Can you check your terminal output?

➜ transparent-background -s images/test.jpg
Settings -> Mode=base, Device=cuda:0, Torchscript=disabled
test.jpg:      100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1/1 [00:02<00:00,  2.72s/it]
Done. Results are saved in /home/user/downloads

If Device=cuda:0 is shown, then it means GPU is used. If Device=cpu is shown, then there is a problem with using GPU.

ttyksi commented 10 months ago

E:\edit>transparent-background --source E:\edit\00216-3043992728.png --type white Settings -> Mode=base, Device=cpu, Torchscript=disabled 00216-3043992728.png: 0%| | 0/1 [00:00<?, ?it/s]

I rechecked and it still seems to be processed in cpu.

plemeri commented 10 months ago

Did you verify your pytorch installation with below script?

import torch
torch.cuda.is_available()

If the result is False, then you need to check if your GPU driver is correctly installed, and PyTorch is correctly installed with GPU acceleration.

ttyksi commented 10 months ago

Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import torch torch.cuda.is_available() True

I ran the script and it seems to be true. I don't want to take up any more of your time, so I would like to reinstall the OS and rebuild the environment. Thanks for your help! And thanks for developing this great software! I will continue to use it.

plemeri commented 10 months ago

Closing due to inactivity. Please open another issue if problem persists.