Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
199 lines (173 loc) · 7.9 KB
/
Copy pathDockerfile
File metadata and controls
199 lines (173 loc) · 7.9 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# syntax=docker/dockerfile:1
ARG CUDA_VERSION=12.2.2
ARG UV_VERSION=0.12.11
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv
# -----------------------------------------------------------------------------
# Rust / CUDA builder
# -----------------------------------------------------------------------------
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu22.04 AS builder
ARG RUST_TOOLCHAIN=stable
ARG CUDA_COMPUTE_CAP=80
ARG CARGO_BUILD_JOBS=1
ARG CARGO_RELEASE_LTO=off
ARG CARGO_RELEASE_CODEGEN_UNITS=8
ARG CARGO_RELEASE_DEBUG=0
ARG CMAKE_BUILD_PARALLEL_LEVEL=2
RUN apt-get -o Acquire::Retries=5 update && \
apt-get -o Acquire::Retries=5 install -y --no-install-recommends \
build-essential \
ca-certificates \
clang \
cmake \
curl \
git \
libssl-dev \
libstdc++-12-dev \
pkg-config && \
update-ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN curl --proto '=https' --tlsv1.2 -sSf \
--retry 6 --retry-all-errors --retry-delay 5 \
--connect-timeout 30 --max-time 300 \
https://sh.rustup.rs \
| sh -s -- -y --default-toolchain "${RUST_TOOLCHAIN}"
ENV PATH=/root/.cargo/bin:${PATH}
ENV CUDA_HOME=/usr/local/cuda
ENV PATH=${CUDA_HOME}/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV CUDA_COMPUTE_CAP=${CUDA_COMPUTE_CAP}
ENV CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS}
ENV CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL}
ENV CARGO_INCREMENTAL=0
# Override only the container's Cargo release profile. The workspace normally
# uses fat LTO + one codegen unit + full debug info, which causes very high
# peak LLVM/linker RAM usage. Cargo officially supports these profile settings
# through CARGO_PROFILE_<name>_* environment variables.
ENV CARGO_PROFILE_RELEASE_LTO=${CARGO_RELEASE_LTO}
ENV CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${CARGO_RELEASE_CODEGEN_UNITS}
ENV CARGO_PROFILE_RELEASE_DEBUG=${CARGO_RELEASE_DEBUG}
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY redeem-openms-ffi ./redeem-openms-ffi
COPY redeem-classifiers ./redeem-classifiers
COPY redeem-cli ./redeem-cli
COPY redeem-properties ./redeem-properties
COPY redeem-properties-py ./redeem-properties-py
COPY scripts ./scripts
# Build the production CLI and the frozen production foundation identifier. Keep
# Cargo parallelism deliberately conservative for workstation image builds;
# this controls peak host RAM and linker pressure without changing the emitted
# model architecture or runtime numerics.
RUN set -eux; \
echo "CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS}"; \
cargo build --release --locked --bin redeem --features cuda; \
FOUNDATION_EXAMPLES="foundation_identify_stream"; \
EXAMPLE_ARGS=""; \
for example_name in ${FOUNDATION_EXAMPLES}; do \
test -f "redeem-properties/examples/${example_name}.rs"; \
EXAMPLE_ARGS="${EXAMPLE_ARGS} --example ${example_name}"; \
done; \
cargo build --release --locked -p redeem-properties --features cuda ${EXAMPLE_ARGS}; \
mkdir -p /opt/redeem/bin; \
cp target/release/redeem /opt/redeem/bin/redeem; \
for example_name in ${FOUNDATION_EXAMPLES}; do \
cp "target/release/examples/${example_name}" "/opt/redeem/bin/${example_name}"; \
done
# -----------------------------------------------------------------------------
# Runtime base. Apt may run while the Rust builder is active, but the expensive
# Python/AlphaPeptDeep installation is deliberately placed in the final stage
# *after* COPY --from=builder, forcing BuildKit to wait for Rust compilation.
# -----------------------------------------------------------------------------
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu22.04 AS runtime-base
RUN apt-get -o Acquire::Retries=5 update && \
apt-get -o Acquire::Retries=5 install -y --no-install-recommends \
bash \
ca-certificates \
libgomp1 \
libssl3 \
libstdc++6 \
python3 \
time && \
update-ca-certificates && \
rm -rf /var/lib/apt/lists/*
ENV CUDA_HOME=/usr/local/cuda
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV VIRTUAL_ENV=/opt/redeem/venv
ENV PATH=/opt/redeem/venv/bin:/opt/redeem/bin:/usr/local/bin:${PATH}
ENV REDEEM_PEPTDEEP_HOME=/opt/redeem/peptdeep
ENV MPLCONFIGDIR=/tmp/redeem-matplotlib
ENV NUMBA_CACHE_DIR=/tmp/redeem-numba
ENV XDG_CACHE_HOME=/tmp/redeem-cache
ENV UV_PYTHON_DOWNLOADS=0
ENV UV_LINK_MODE=copy
ENV UV_HTTP_RETRIES=10
ENV UV_HTTP_TIMEOUT=120
FROM runtime-base AS runtime
ARG PEPTDEEP_VERSION=1.5.1
ARG PEPTDEEP_TORCH_VERSION=2.5.1
ARG PEPTDEEP_TORCH_VARIANT=cpu
ARG INSTALL_ALPHAPEPTDEEP=1
ARG PRELOAD_ALPHAPEPTDEEP_MODELS=1
ARG PYTHON_BUILD_THREADS=1
# IMPORTANT: this dependency edge serializes the two high-pressure phases.
# Python / torch / AlphaPeptDeep installation cannot begin until the complete
# CUDA/Rust builder has finished and its binaries have been copied.
COPY --from=builder /opt/redeem/bin/ /opt/redeem/bin/
COPY --from=uv /uv /uvx /usr/local/bin/
WORKDIR /work
COPY redeem-properties/nbs/redeem_foundation_validation_report.ipynb /opt/redeem/notebooks/redeem_foundation_validation_report.ipynb
ENV MAX_JOBS=${PYTHON_BUILD_THREADS}
ENV CMAKE_BUILD_PARALLEL_LEVEL=${PYTHON_BUILD_THREADS}
ENV OMP_NUM_THREADS=${PYTHON_BUILD_THREADS}
ENV OPENBLAS_NUM_THREADS=${PYTHON_BUILD_THREADS}
ENV MKL_NUM_THREADS=${PYTHON_BUILD_THREADS}
ENV UV_CONCURRENT_BUILDS=${PYTHON_BUILD_THREADS}
# AlphaPeptDeep comparison is intentionally CPU-only. ReDeeM/Candle remains CUDA-enabled.
# Use pinned uv for virtualenv creation and Python dependency installation. The
# official CPU torch index remains explicit so the descriptive AlphaPeptDeep lane
# cannot pull a second CUDA runtime into the CUDA 12.2 ReDeeM image. BuildKit's
# uv cache mount persists downloaded wheels and resolver metadata across rebuilds.
RUN --mount=type=cache,target=/root/.cache/uv \
uv venv --python /usr/bin/python3 "${VIRTUAL_ENV}"
RUN --mount=type=cache,target=/root/.cache/uv \
if [ "${INSTALL_ALPHAPEPTDEEP}" = "1" ]; then \
test "${PEPTDEEP_TORCH_VARIANT}" = "cpu"; \
uv pip install --python "${VIRTUAL_ENV}/bin/python" \
--default-index https://download.pytorch.org/whl/cpu \
"torch==${PEPTDEEP_TORCH_VERSION}"; \
fi
RUN --mount=type=cache,target=/root/.cache/uv \
if [ "${INSTALL_ALPHAPEPTDEEP}" = "1" ]; then \
uv pip install --python "${VIRTUAL_ENV}/bin/python" \
"peptdeep[stable]==${PEPTDEEP_VERSION}" \
"nbconvert>=7,<8" \
"matplotlib>=3.7"; \
uv pip check --python "${VIRTUAL_ENV}/bin/python"; \
"${VIRTUAL_ENV}/bin/python" -c 'import torch; print("AlphaPeptDeep torch:", torch.__version__, "cuda_available=", torch.cuda.is_available()); assert "+cpu" in torch.__version__; assert not torch.cuda.is_available()'; \
fi
RUN if [ "${INSTALL_ALPHAPEPTDEEP}" = "1" ] && [ "${PRELOAD_ALPHAPEPTDEEP_MODELS}" = "1" ]; then \
mkdir -p /opt/redeem; \
success=0; \
for attempt in 1 2 3 4 5; do \
if HOME=/opt/redeem "${VIRTUAL_ENV}/bin/peptdeep" install-models --overwrite True; then \
success=1; \
break; \
fi; \
echo "AlphaPeptDeep model download attempt ${attempt} failed; retrying..." >&2; \
sleep $((attempt * 10)); \
done; \
test "${success}" = "1"; \
fi
# Foundation corpus ingestion deliberately streams compressed inputs through
# system decompressors (zstd -dc / gzip -dc). Install these in a late runtime
# layer so adding them does not invalidate the expensive Rust/CUDA or Python/APD
# build layers that are already cached.
RUN apt-get -o Acquire::Retries=5 update && \
apt-get -o Acquire::Retries=5 install -y --no-install-recommends \
gzip \
zstd && \
command -v gzip && \
command -v zstd && \
rm -rf /var/lib/apt/lists/*
RUN foundation_identify_stream --self-test
CMD ["foundation_identify_stream", "--help"]