Skip to content

Commit d6ac01f

Browse files
authored
Merge pull request #757 from Yahweasel/main
2 parents 3b6bf90 + ac0fa9a commit d6ac01f

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pip install rembg[cpu] # for library
109109
pip install "rembg[cpu,cli]" # for library + cli
110110
```
111111

112-
### GPU support:
112+
### GPU support (NVidia/Cuda):
113113

114114
First of all, you need to check if your system supports the `onnxruntime-gpu`.
115115

@@ -128,6 +128,19 @@ pip install "rembg[gpu,cli]" # for library + cli
128128

129129
Nvidia GPU may require onnxruntime-gpu, cuda, and cudnn-devel. [#668](https://github.com/danielgatis/rembg/issues/668#issuecomment-2689830314) . If rembg[gpu] doesn't work and you can't install cuda or cudnn-devel, use rembg[cpu] and onnxruntime instead.
130130

131+
### GPU support (AMD/ROCM):
132+
133+
ROCM support requires the `onnxruntime-rocm` package. Install it following
134+
[AMD's documentation](https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/native_linux/install-onnx.html).
135+
136+
If `onnxruntime-rocm` is installed and working, install the `rembg[rocm]`
137+
version of rembg:
138+
139+
```bash
140+
pip install "rembg[rocm]" # for library
141+
pip install "rembg[rocm,cli]" # for library + cli
142+
```
143+
131144
## Usage as a cli
132145

133146
After the installation step you can use rembg just typing `rembg` in your terminal window.

rembg/sessions/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def __init__(self, model_name: str, sess_opts: ort.SessionOptions, *args, **kwar
2020
and "CUDAExecutionProvider" in ort.get_available_providers()
2121
):
2222
providers = ["CUDAExecutionProvider", "CPUExecutionProvider"]
23+
elif (
24+
device_type[0:3] == "GPU"
25+
and "ROCMExecutionProvider" in ort.get_available_providers()
26+
):
27+
providers = ["ROCMExecutionProvider", "CPUExecutionProvider"]
2328
else:
2429
providers = ["CPUExecutionProvider"]
2530

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
],
3939
"cpu": ["onnxruntime"],
4040
"gpu": ["onnxruntime-gpu"],
41+
"rocm": ["onnxruntime-rocm"],
4142
"cli": [
4243
"aiohttp",
4344
"asyncer",

0 commit comments

Comments
 (0)