Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
models/
.git
__pycache__
*.pyc
*.pyo
.ipynb_checkpoints
.eggs
*.egg-info
dist
build
.venv
venv
.env
*.pt
*.pth
*.bin
*.onnx
output
outputs
wandb
.ml-cache
.mypy_cache
.pytest_cache
.ruff_cache
.pre-commit-cache
54 changes: 54 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Push Docker Image

on:
push:
branches:
- main
- add-docker

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Docker
models/

# Python cache
__pycache__/
*.py[cod]
Expand Down
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN apt-get update && apt-get install -y --no-install-recommends \
python3.11 \
python3.11-dev \
python3.11-venv \
python3-pip \
git \
git-lfs \
ffmpeg \
cmake \
ninja-build \
libgl1-mesa-glx \
libglib2.0-0 \
&& ln -sf /usr/bin/python3.11 /usr/bin/python \
&& ln -sf /usr/bin/python3.11 /usr/bin/python3 \
&& rm -rf /var/lib/apt/lists/*

ENV CUDA_HOME=/usr/local/cuda
ENV PATH="${CUDA_HOME}/bin:${PATH}"
ENV LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"

RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel

WORKDIR /app

COPY pyproject.toml README.md ./
COPY src/ src/

RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu124

RUN pip install --no-cache-dir xformers --index-url https://download.pytorch.org/whl/cu124

ENV TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;8.9;9.0"

RUN pip install --no-cache-dir hatchling hatch-vcs editables && \
pip install --no-cache-dir -e ".[all]" --no-build-isolation

EXPOSE 7860

ENTRYPOINT ["da3"]
CMD ["gradio"]
24 changes: 24 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
# Use: docker exec -it da3-backend bash
# To create a bash session inside the container to run commands like: da3 auto --use-backend --backend-url http://localhost:7860 --export-dir workspace/gallery/scene001 workspace/input
da3-backend:
container_name: da3-backend
image: ghcr.io/bytedance-seed/depth-anything-3:main
command: backend --model-dir depth-anything/DA3-LARGE-1.1 --port 7860 --host 0.0.0.0 --allow-unauthenticated
build:
dockerfile: Dockerfile
context: .
tty: true
stdin_open: true
ports:
- 7860:7860
volumes:
- ./workspace:/app/workspace
- ./models:/root/.cache/huggingface/hub
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all # To use specifics GPUs --> device_ids: ['0']
capabilities: [ gpu ]