-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (51 loc) · 2.28 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (51 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# ==========================================
# DOMINO — Whole Head Segmentation (GPU)
# Multi-stage build; CUDA-enabled PyTorch
# ==========================================
# ---------- Stage 1: builder (installs deps into a venv) ----------
# Pick a base matching your host driver stack; CUDA 12.1 is widely supported.
FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-runtime AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=100
WORKDIR /workspace
# Copy only requirements first to maximize Docker layer caching
COPY requirements.txt /workspace/requirements.txt
# Create an isolated virtualenv and install deps (incl. MONAI/PyTorch add-ons from requirements.txt)
RUN python -m venv /opt/venv && \
. /opt/venv/bin/activate && \
pip install --upgrade pip wheel && \
pip install -r /workspace/requirements.txt
# ---------- Stage 2: runtime (final, smaller image) ----------
FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-runtime AS runtime
# tini = clean signal handling; ca-certificates for HTTPS; jq/coreutils handy for ops
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates tini gosu jq coreutils && \
rm -rf /var/lib/apt/lists/*
# Bring the prebuilt venv from builder
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:${PATH}" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
RUNTIME_DEVICE=auto \
PYTORCH_ENABLE_MPS_FALLBACK=1
# Project source (your repo root). Contains your Python code + the three scripts.
WORKDIR /workspace
COPY . /workspace
# A tiny generic preprocessor (fallback) that can do the full pipeline if desired.
# You can ignore it—your three scripts are used by default.
# RUN mkdir -p /opt/domino/bin
# Entrypoint that dispatches: preprocess | train | test
COPY ./entrypoint.sh /opt/domino/entrypoint.sh
RUN chmod +x /opt/domino/entrypoint.sh
# Defaults (can be overridden at runtime)
ENV DOMINO_DATA_DIR=/data \
DOMINO_WORKDIR=/workspace \
DOMINO_PREPROCESS_SCRIPT=/workspace/preprocess.py \
DOMINO_TRAIN_SCRIPT=/workspace/train.py \
DOMINO_TEST_SCRIPT=/workspace/test.py
# tini = PID1 for clean signal handling
ENTRYPOINT ["/usr/bin/tini", "--", "/opt/domino/entrypoint.sh"]
CMD ["--help"]