-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathDockerfile
More file actions
104 lines (85 loc) · 3.46 KB
/
Copy pathDockerfile
File metadata and controls
104 lines (85 loc) · 3.46 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
# bitmind-subnet Validator stack image.
# One image; run as validator, generator, or data via SERVICE=validator|generator|data.
# Compose starts three containers with shared volumes.
# ---------------------------------------------------------------------------
# Build stage: install all Python dependencies
# ---------------------------------------------------------------------------
FROM nvidia/cuda:12.4.1-devel-ubuntu22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1
# System build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
cmake \
git \
wget \
curl \
python3.10 \
python3.10-dev \
python3.10-venv \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Make python3.10 the default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH"
WORKDIR /app
# Copy dependency files first for layer caching
COPY pyproject.toml uv.lock VERSION ./
# Create venv and install dependencies (frozen = use lockfile exactly)
RUN uv sync --frozen
# Copy full project source
COPY . .
# Install the gas package (editable) and additional git dependencies.
# One of these (Janus/diffusers/CLIP) uses setuptools at build time without declaring it,
# so we install setuptools and use --no-build-isolation for these installs only. In Docker
# this is safe: the build env is fixed (only uv sync + setuptools), so the build is
# reproducible. uv's extra-build-dependencies does not work reliably with setuptools.
RUN uv pip install setuptools && \
uv pip install -e . && \
uv pip install --no-build-isolation \
git+https://github.com/deepseek-ai/Janus.git \
git+https://github.com/openai/CLIP.git
# ---------------------------------------------------------------------------
# Runtime stage: slim image with only what's needed to run
# ---------------------------------------------------------------------------
FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Runtime system dependencies (gcc + python3.10-dev for Triton/bitsandbytes JIT C compile at import)
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.10 \
python3.10-venv \
python3.10-dev \
build-essential \
ffmpeg \
wget \
&& rm -rf /var/lib/apt/lists/*
# Make python3.10 the default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
WORKDIR /app
# Copy entire project (including .venv and docker/) from builder
COPY --from=builder /app /app
RUN chmod +x /app/docker/entrypoint.sh
# Ensure cache directories exist
RUN mkdir -p /root/.cache/sn34/tmp /root/.cache/huggingface /root/.bittensor/wallets
# Default environment
ENV PATH="/app/.venv/bin:$PATH"
ENV SN34_CACHE_DIR=/root/.cache/sn34
ENV HF_HOME=/root/.cache/huggingface
ENV HF_HUB_DISABLE_TELEMETRY=1
ENV TRANSFORMERS_VERBOSITY=error
ENV DIFFUSERS_VERBOSITY=error
ENV TOKENIZERS_PARALLELISM=false
ENV HF_HUB_VERBOSITY=error
ENV ACCELERATE_LOG_LEVEL=error
ENV TMPDIR=/root/.cache/sn34/tmp
ENV TEMP=/root/.cache/sn34/tmp
ENV TMP=/root/.cache/sn34/tmp
ENV DISPLAY=:99
ENTRYPOINT ["/app/docker/entrypoint.sh"]