Why does every “simple” remove background AI install stall on the first real image? I hit that wall deploying rembg 2.0.84 – wrong Python, a ~1 GB default model, and a GPU that pretended to work. This walkthrough gets you from zero to a verified cutout without the outdated u2net-only scripts still floating around.
rembg is the open-source local tool (CLI, library, HTTP server, Docker) from danielgatis/rembg. Offline after models cache. Code is MIT; some weight files are not. Confirm the 2.0.84 tag on GitHub Releases and PyPI before you pin – do not trust mirrored “latest” blog numbers.
System requirements before you touch pip
Python gate first. Official README: >= 3.11 and < 3.14. onnxruntime is why that band exists.
python3 --version
# expect 3.11.x, 3.12.x, or 3.13.x
Windows, macOS, Linux all work. What the default model actually forces on a desk (operator judgment, not a vendor matrix):
| Resource | Minimum to install | Comfortable for default model |
|---|---|---|
| RAM | 4 GB (tiny models only) | 8-16 GB (bria-rmbg ~1.02 GB on disk, heavier resident) |
| Disk free | ~500 MB package + onnxruntime | 3+ GB if you keep several ONNX files |
| GPU (optional) | None – CPU path works | NVIDIA + matching CUDA/cuDNN for onnxruntime-gpu, or AMD ROCm |
Prove the pipeline on CPU before you touch GPU extras. Most “GPU install failed” threads are CUDA/cuDNN skew, not rembg itself.
Official download sources (use these only)
- Source / docs:https://github.com/danielgatis/rembg
- Python package:https://pypi.org/project/rembg/ – pin
2.0.84after you verify the tag - Docker:
danielgatis/rembgon Docker Hub (tag2.0.84or a digest you trust) - Release notes: same GitHub Releases page for the tag you install
Pin in production. A naked pip install -U will change behavior under you.
Install rembg 2.0.84 step by step
Virtualenv. Always. Global site-packages and distro Python fight you later.
python3 -m venv ~/.venvs/rembg
source ~/.venvs/rembg/bin/activate # Windows: .venvScriptsactivate
python -m pip install -U pip
# CPU + CLI (recommended first path)
python -m pip install "rembg[cpu,cli]==2.0.84"
# NVIDIA GPU path (only after checking onnxruntime.ai install matrix)
# python -m pip install "rembg[gpu,cli]==2.0.84"
# AMD ROCm: install onnxruntime-rocm per AMD docs first, then:
# python -m pip install "rembg[rocm,cli]==2.0.84"
Quotes around extras matter on zsh. Library-only? Drop cli – rembg[cpu] – if you only import.
Pro tip: Prefetch before a demo or CI job:
rembg d bria-rmbg. First inference otherwise blocks on a ~1.02 GB fetch into the model cache.
Docker CPU (no local Python):
docker pull danielgatis/rembg:2.0.84
docker run --rm -v "$PWD":/data danielgatis/rembg:2.0.84 i /data/input.png /data/output.png
GPU image is not a Hub one-liner. Build Dockerfile_nvidia_cuda_cudnn_gpu from the repo (NVIDIA Container Toolkit; ballpark ~11 GB disk vs ~1.6 GB compressed CPU). Tag 2.0.84 added missing git in that Dockerfile. Mount -v /path/to/models:/root/.rembg so every container does not re-download weights.
First-time configuration that actually matters
No config file. Extras, env vars, and the model name you pass drive behavior.
- Model home: New files land in
~/.rembg/models/<model>/(or$REMBG_HOME). Legacy flat~/.u2net/is still read. PreferREMBG_HOME. - Migrate old caches:
rembg mmoves legacy trees into the new layout without re-downloading when the files are intact (README models/storage section). - Default model trap: In the 2.0.8x line the default is bria-rmbg – strong edges, slower than u2net, ~1.02 GB, 1024×1024. Weights use BRIA terms: commercial use needs a paid BRIA agreement. rembg’s MIT license does not cover those weights. Need speed or clear shop rights? Force
-m u2net(or another model you have actually cleared).
That license split is the line I wish the first tutorial I followed had printed in bold.
Verify the install works
rembg --version
# rembg, version 2.0.84
rembg d bria-rmbg # or: rembg d u2net
rembg i path/to/sample.jpg path/to/sample.out.png
Library smoke test:
python -c "from rembg import remove; print('ok')"
Optional server: rembg s --host 127.0.0.1 --port 7000, then http://127.0.0.1:7000/api. Add --no-ui if an optional front-end is chewing idle CPU you do not want.
On GPU builds, watch stderr on first session create. 2.0.83+ warns when you asked for CUDA (or another accelerator) and the session fell back to CPU – the old silent 10-20× slowdown (release notes / #841-class fixes).
Common install errors and fixes
“No onnxruntime backend found” on Windows after a clean rembg[cpu] install? Thread #826 pins missing Microsoft Visual C++ 2015-2022 Redistributable (x64), not a wrong extras string. Install the redist, reboot if Windows asks, then pip install "rembg[cpu,cli]==2.0.84" --force-reinstall.
CLI says CLI dependencies are not installed: library-only extras. Put ,cli back in the brackets.
GPU path installs but runs like a potato: onnxruntime-gpu wants matching CUDA/cuDNN – start at the onnxruntime install matrix, not random blog CUDA builds. Incomplete libs? Fall back to rembg[cpu,cli] instead of burning an afternoon. Remember the 2.0.83 warning above: “installed GPU” is not the same as “session using GPU.”
First run “hangs”: model download. Prefetch with rembg d .... Partial junk under the cache dir is common on flaky links; clear orphans carefully, then retry.
Python 3.10 or 3.14: outside the supported band. 3.12 is the boring safe middle.
Upgrade, migrate, uninstall
# upgrade inside the same venv
python -m pip install -U "rembg[cpu,cli]==2.0.84"
# after jumps from old caches
rembg m
# uninstall package only
python -m pip uninstall rembg
# full cleanup: package + model cache (destructive)
# rm -rf ~/.rembg ~/.u2net # Unix
# rmdir /s %USERPROFILE%.rembg & same for .u2net on Windows
Docker: pull the new tag, recreate containers. Rebuild the NVIDIA Dockerfile when the GPU image must move – Hub CPU tags do not replace that custom build.
After install sticks: rembg p for folders, rembg b for FFmpeg RGB24 pipes, or cutouts dropped into an art pipeline. Keep model name + license next to the deploy notes.
Grab one product photo. Run rembg i with an explicit -m you have licensed. Check PNG alpha before you script a hundred more.
FAQ
What is the latest rembg version I should install?
Pin ==2.0.84 after you confirm that tag on PyPI and GitHub Releases. Reproducible beats floating latest.
Do I need a GPU for remove background AI with rembg?
No. CPU extras are the path most laptops should start on. Product shots and simple portraits finish in a few seconds on a modern CPU with u2net or u2netp. Bring GPU when you batch thousands of frames or insist on heavy 1024×1024 defaults and care about latency. CUDA fight? Stay on CPU – same weights, longer wall clock.
Why is the first run huge and is the default model free for shops?
Default weights are bria-rmbg (~1.02 GB). MIT covers rembg’s code, not those weights – BRIA’s terms expect a paid agreement for commercial use. Read the model card before client catalogs. Many teams still pass -m u2net / u2netp after checking each license. Prefetch with rembg d. Files live under ~/.rembg/models/; rembg m migrates older ~/.u2net trees instead of deleting them.