1616ARG BASE_IMAGE="nvcr.io/nvidia/cuda-dl-base"
1717ARG BASE_IMAGE_TAG="25.03-cuda12.8-devel-ubuntu24.04"
1818
19- FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG}
20-
19+ # UCX argument is either "upstream" (default installed in base image) or "custom" (build from source)
20+ ARG UCX= "upstream"
2121ARG DEFAULT_PYTHON_VERSION="3.12"
2222
23+ # --- Stage 1: Common OS setup ---
24+ FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} AS os_setup_stage
25+
26+ # Re-declare for use in this stage
27+ ARG DEFAULT_PYTHON_VERSION
2328RUN apt-get update -y && \
2429 DEBIAN_FRONTEND=noninteractive apt-get -y install \
2530 ninja-build \
@@ -34,6 +39,44 @@ RUN apt-get update -y && \
3439 etcd-server \
3540 etcd-client
3641
42+ # --- Stage 2a: Represents using UCX from the base image ---
43+ FROM os_setup_stage AS ucx_upstream_image
44+ RUN echo "INFO: Using UCX from base image (UCX=${UCX})."
45+
46+ # --- Stage 2b: Represents building UCX from source ---
47+ FROM os_setup_stage AS ucx_custom_image
48+ RUN mkdir -p /workspace/ucx
49+ COPY --from=ucx . /workspace/ucx
50+
51+ RUN echo "INFO: Starting custom UCX build..." && \
52+ apt-get update -y && \
53+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
54+ autoconf automake libtool pkg-config make g++ \
55+ libnuma-dev librdmacm-dev ibverbs-providers && \
56+ echo "INFO: Removing pre-existing UCX installations..." && \
57+ rm -rf /usr/local/ucx /opt/hpcx/ucx && \
58+ cd /workspace/ucx && \
59+ ./autogen.sh && \
60+ echo "INFO: Building UCX..." && \
61+ ./contrib/configure-release --prefix=/usr/local/ucx \
62+ --with-cuda=/usr/local/cuda \
63+ --enable-mt \
64+ --without-go && \
65+ make -j$(nproc) && \
66+ make install && \
67+ cd / && \
68+ echo "INFO: Finished building and installing UCX to /usr/local/ucx."
69+
70+ # --- Stage 3: UCX Image Selection ---
71+ # This stage selects the correct UCX image based on the UCX argument
72+ FROM ucx_${UCX}_image AS ucx_image
73+
74+ # --- Stage 4: Final Image Assembly ---
75+ # Re-declare ARGs needed in this final stage
76+ ARG DEFAULT_PYTHON_VERSION
77+ ARG WHL_PYTHON_VERSIONS="3.12"
78+ ARG WHL_PLATFORM="manylinux_2_39_x86_64"
79+
3780WORKDIR /workspace
3881RUN git clone https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3.git &&\
3982 cd etcd-cpp-apiv3 && mkdir build && cd build && \
@@ -67,8 +110,6 @@ RUN echo "/usr/local/nixl/lib/x86_64-linux-gnu" > /etc/ld.so.conf.d/nixl.conf &&
67110 ldconfig
68111
69112# Create the wheel
70- ARG WHL_PYTHON_VERSIONS="3.12"
71- ARG WHL_PLATFORM="manylinux_2_39_x86_64"
72113RUN IFS=',' read -ra PYTHON_VERSIONS <<< "$WHL_PYTHON_VERSIONS" && \
73114 for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}" ; do \
74115 uv build --wheel --out-dir /tmp/dist --python $PYTHON_VERSION; \
0 commit comments