diff --git a/Dockerfile b/Dockerfile index a03cca18..c9cc3974 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ -FROM python:3.10-slim +FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 WORKDIR /rembg COPY . . +RUN apt-get update +RUN apt-get install -y python-is-python3 python3 python3-pip RUN python -m pip install ".[gpu,cli]" RUN python -c 'from rembg.bg import download_models; download_models()' diff --git a/rembg/Makefile b/rembg/Makefile new file mode 100644 index 00000000..f120b6c3 --- /dev/null +++ b/rembg/Makefile @@ -0,0 +1,61 @@ +# keep help at the beginning - this will be used as default command +.description: Generate list of targets with descriptions +help: + @grep -oz '^.description: .*\n.*:' Makefile | sed 'N;s;\.description: \(.*\)\n\(.*\):;"\x1b[1\;32m make \2 \x1b[0m" "\1";' | xargs printf "%-50s - %s\n" + +# MACROS + +DOCKER = docker-compose -f docker-compose.development.yml +DOCKER_DEV = $(DOCKER) +CFLAGS='-Wno-warning' + +# use the rest as arguments for "run" +ARGS = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}` + +# COMMANDS + +# common +.description: start all services in DEVELOPMENT environment +start: + make stop backend + $(DOCKER_DEV) --profile all up -d + +.description: stop all app services. You can pass service name as an argument +stop: + $(DOCKER) --profile all stop $(call ARGS) + +.description: stop all services +down: + $(DOCKER) --profile all down + +.description: build docker images +build: + $(DOCKER_DEV) --profile all build + +.description: docker logs with follow option. You can pass service name as argument. +flogs: + $(DOCKER) logs --follow $(call ARGS) + +.description: docker logs. You can pass service name as argument. +logs: + $(DOCKER) logs $(call ARGS) + +.description: exec in the running service (pass service name and command as an argument). `make exec redis redis-cli` +exec: + $(DOCKER) exec $(call ARGS) + +.description: attaches to backend process stdin +attach: + docker attach --detach-keys=ctrl-c $$($(DOCKER_DEV) ps -q backend) + +.description: launches bash in backend container +bash: + $(DOCKER_DEV) exec backend bash + +# Ignore unknown targets +%: + @: + +# ...and turn them into do-nothing targets +_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) +$(eval $(_ARGS):dummy;@:) diff --git a/rembg/docker-compose.development.yml b/rembg/docker-compose.development.yml new file mode 100644 index 00000000..c6455bb3 --- /dev/null +++ b/rembg/docker-compose.development.yml @@ -0,0 +1,12 @@ +services: + backend: + profiles: + - all + build: + context: . + tty: true + stdin_open: true + ports: + - "6100:7000" + environment: + OMP_NUM_THREADS: 4 diff --git a/setup.py b/setup.py index 969e410f..8b118178 100644 --- a/setup.py +++ b/setup.py @@ -85,7 +85,6 @@ python_requires=">=3.8, <3.13", packages=find_packages(), install_requires=install_requires, - dependency_links=['https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/'], entry_points=entry_points, extras_require=extras_require, version=versioneer.get_version(),