-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile
More file actions
107 lines (90 loc) · 3.85 KB
/
Dockerfile
File metadata and controls
107 lines (90 loc) · 3.85 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Multi-stage Dockerfile for scenesmith.
# Single-container setup: all servers (geometry generation, retrieval, blender,
# etc.) are auto-managed by the pipeline inside the container.
# =============================================================================
# Stage 1: Base system with Python 3.11 and system dependencies.
# =============================================================================
FROM nvidia/cuda:12.4.0-devel-ubuntu22.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
# Install Python 3.11 via deadsnakes PPA and system packages.
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update && apt-get install -y --no-install-recommends \
python3.11 \
python3.11-dev \
python3.11-venv \
python3.11-distutils \
libpython3.11-dev \
git \
git-lfs \
wget \
unzip \
bubblewrap \
cmake \
build-essential \
# X11/EGL libs for headless Blender rendering.
libgl1 \
libegl1 \
libxrender1 \
libxkbcommon0 \
libsm6 \
libxext6 \
libxi6 \
libxxf86vm1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Set Python 3.11 as default.
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
# Install uv package manager.
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
# Set environment variables.
ENV CUDA_HOME=/usr/local/cuda-12.4
ENV PATH="${CUDA_HOME}/bin:${PATH}"
ENV LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics
WORKDIR /app
# =============================================================================
# Stage 2: Python dependencies.
# =============================================================================
FROM base AS deps
COPY pyproject.toml uv.lock .python-version README.md ./
RUN uv sync --frozen --no-dev
# =============================================================================
# Stage 3: SAM3D backend (optional but included in image).
# =============================================================================
FROM deps AS sam3d
COPY scripts/install_sam3d_docker.sh scripts/install_sam3d_docker.sh
# Disable uv project config to avoid hitting the Blender PyPI index
# (from pyproject.toml) which rate-limits during Docker builds.
# Set TORCH_CUDA_ARCH_LIST since no GPU is available during build.
# Covers Ampere (A100, A10), Ada Lovelace (L40S, RTX 4090), Hopper (H100).
RUN UV_NO_CONFIG=1 TORCH_CUDA_ARCH_LIST="8.0;8.6;8.9;9.0" \
bash scripts/install_sam3d_docker.sh
# =============================================================================
# Stage 4: Application code.
# =============================================================================
FROM sam3d AS app
# Copy full repo source.
COPY . .
# Remove stale bytecode from earlier stages (SAM3D install imports
# scenesmith, creating .pyc that would shadow updated .py files).
RUN find /app/scenesmith -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null; true
# Activate the virtual environment by prepending it to PATH.
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# Default command: print usage help.
CMD ["python", "-c", \
"print('scenesmith Docker container\\n')\n\
print('Usage examples:\\n')\n\
print(' # Smoke test')\n\
print(' docker run --gpus all scenesmith python -c \"import torch; print(torch.cuda.is_available()); import scenesmith\"\\n')\n\
print(' # Run unit tests')\n\
print(' docker run --gpus all scenesmith pytest tests/unit/ -x\\n')\n\
print(' # Run scene generation (requires data volumes and API keys)')\n\
print(' docker compose up\\n')\n\
print('See README.md for full documentation.')"]