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 @@
.git
.gitignore
.github

__pycache__/
*.pyc
*.pyo
*.pyd

.pytest_cache/
.mypy_cache/
.ruff_cache/
.venv/
.ipynb_checkpoints/

build/
dist/
*.egg-info/
.eggs/

checkpoints/
outputs/
*.pt
*.pth
*.ckpt
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM python:3.12-slim

ARG TORCH_VERSION=2.7.0
ARG TORCH_INDEX_URL=https://download.pytorch.org/whl/cu126
ARG SAM3_EXTRAS=""

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
git \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install torch early to leverage Docker layer caching.
RUN python -m pip install --upgrade pip \
&& pip install torch==${TORCH_VERSION} torchvision torchaudio --index-url ${TORCH_INDEX_URL}

COPY . /app

RUN if [ -n "${SAM3_EXTRAS}" ]; then \
pip install -e ".[${SAM3_EXTRAS}]"; \
else \
pip install -e .; \
fi

CMD ["bash"]
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ pip install -e ".[notebooks]"
pip install -e ".[train,dev]"
```

### Docker (GPU)

Build the image (defaults to CUDA 12.6 wheels):

```bash
docker build -t sam3:latest .
```

Run with GPU access:

```bash
docker run --gpus all -it --rm \
-v "$(pwd)":/app \
-v "$HOME/.cache/huggingface":/root/.cache/huggingface \
sam3:latest
```

Optional build args:

```bash
# CPU-only wheels
docker build --build-arg TORCH_INDEX_URL=https://download.pytorch.org/whl/cpu -t sam3:cpu .

# Install extras (comma-separated)
docker build --build-arg SAM3_EXTRAS=train,dev -t sam3:train .
```

## Getting Started

⚠️ Before using SAM 3, please request access to the checkpoints on the SAM 3
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
sam3:
build:
context: .
args:
TORCH_VERSION: "2.7.0"
TORCH_INDEX_URL: "https://download.pytorch.org/whl/cu126"
SAM3_EXTRAS: ""
image: sam3:latest
working_dir: /app
volumes:
- .:/app
- ${HOME}/.cache/huggingface:/root/.cache/huggingface
environment:
HF_HOME: /root/.cache/huggingface
gpus: all
stdin_open: true
tty: true
command: bash