Repository navigation
Expand file tree
/
Copy pathDockerfile.gpu
More file actions
98 lines (80 loc) · 4.58 KB
/
Copy pathDockerfile.gpu
File metadata and controls
98 lines (80 loc) · 4.58 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
FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu24.04 AS base
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates curl bash tar xz-utils gcc g++ libhdf5-dev libclang-dev perl make libsasl2-dev libsasl2-2 default-jre-headless pkg-config python3 python3-pip python3-venv libcfitsio-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal
ENV PATH="/root/.cargo/bin:/usr/local/cuda/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib:/usr/local/cuda/lib"
ENV LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/targets/x86_64-linux/lib:/usr/local/cuda/lib"
WORKDIR /app
FROM base AS builder
ARG ONNXRUNTIME_GPU_VERSION=1.24.4
# Compiled into the binaries and recorded on every data mutation, so the ledger
# can name the commit that produced a change. Absent when unset -- the ledger
# records that honestly rather than inventing a value.
ARG BOOM_GIT_SHA
ENV BOOM_GIT_SHA=${BOOM_GIT_SHA}
RUN python3 -m venv /opt/ort-py && \
/opt/ort-py/bin/pip install --no-cache-dir "onnxruntime-gpu==${ONNXRUNTIME_GPU_VERSION}" && \
true
RUN ORT_CAPI_DIR="$('/opt/ort-py/bin/python' -c 'import pathlib, onnxruntime as ort; print(pathlib.Path(ort.__file__).resolve().parent / "capi")')" && \
mkdir -p /opt/ort && \
cp "${ORT_CAPI_DIR}/libonnxruntime.so.${ONNXRUNTIME_GPU_VERSION}" /opt/ort/ && \
cp "${ORT_CAPI_DIR}/libonnxruntime_providers_cuda.so" /opt/ort/ && \
cp "${ORT_CAPI_DIR}/libonnxruntime_providers_shared.so" /opt/ort/ && \
cp "${ORT_CAPI_DIR}/libonnxruntime_providers_tensorrt.so" /opt/ort/ && \
rm -rf /opt/ort-py && ln -sf /opt/ort/libonnxruntime.so.${ONNXRUNTIME_GPU_VERSION} /opt/ort/libonnxruntime.so
COPY data/models/btsbot-v2.0.0.onnx /app/data/models/btsbot-v2.0.0.onnx
COPY apache-avro-macros /app/apache-avro-macros
COPY Cargo.toml Cargo.lock build.rs /app/
# build.rs generates the Milvus gRPC bindings from these vendored protos into
# OUT_DIR; without them src/milvus/proto.rs has nothing to include!().
COPY ./proto /app/proto
COPY ./schemas /app/schemas
COPY ./src /app/src
# BuildKit cache mounts keep compiled crates (target/) and fetched deps between
# builds so only changed crates recompile. The cache mount is not part of the
# image, so the release binaries are copied out to /app/bin in the same RUN.
# (rustup here puts CARGO_HOME at /root/.cargo, unlike the rust:slim image.)
RUN --mount=type=cache,target=/app/target,sharing=locked \
--mount=type=cache,target=/root/.cargo/registry,sharing=locked \
--mount=type=cache,target=/root/.cargo/git,sharing=locked \
cargo build --release --features gpu --bin scheduler --bin task_worker && \
mkdir -p /app/bin && \
cp target/release/scheduler \
target/release/task_worker \
/app/bin/
FROM nvidia/cuda:12.8.1-cudnn-runtime-ubuntu24.04 AS app
ARG UV_VERSION=0.10.0
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates curl bash libsasl2-2 libcfitsio10t64 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# boompy fetches archival catalogs -- see boompy/README.md. Needed here because
# docker-compose.cuda.yaml puts the task worker on this image, and a task worker
# claims whatever is queued, including a catalog ingest.
RUN curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | \
env UV_INSTALL_DIR=/usr/local/bin UV_UNMANAGED_INSTALL=1 sh
ENV ORT_DYLIB_PATH=/opt/ort/libonnxruntime.so
# Prepend /opt/ort so the ORT provider shared libraries are found;
# CUDA library paths (/usr/local/cuda/lib64, etc.) are already in LD_LIBRARY_PATH from the base image.
ENV LD_LIBRARY_PATH=/opt/ort:${LD_LIBRARY_PATH}
WORKDIR /app
# The scheduler and the task worker. The migration binaries became task types
# (see docs/task-system.md), and the task worker is on this image because
# `enrich_reprocess` loads the ONNX models in-process -- on a GPU deployment it
# has to run where the GPU is.
COPY --from=builder /app/bin/scheduler /app/scheduler
COPY --from=builder /app/bin/task_worker /app/task_worker
COPY --from=builder /opt/ort /opt/ort
RUN mkdir -p /app/data/kernels && \
curl -fsSL -o /app/data/kernels/de440s.bsp https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440s.bsp && \
chmod 644 /app/data/kernels/de440s.bsp
# Resolved at build time from the committed lockfile, so a catalog ingest does
# not depend on PyPI being reachable.
COPY boompy /app/boompy
ENV UV_PROJECT_ENVIRONMENT=/app/boompy/.venv
ENV BOOM_BOOMPY_PATH=/app/boompy
RUN uv sync --project /app/boompy --frozen --no-dev
CMD ["/app/scheduler"]