Skip to content

Commit 9f00c7c

Browse files
authored
Benchmark: make it possible to build container with UCX built from source (#306)
* Support building UCX from source * Make nixl optional, just point to repo root * Address comments * fix indentation
1 parent 1a4a6ae commit 9f00c7c

File tree

2 files changed

+62
-8
lines changed

2 files changed

+62
-8
lines changed

benchmark/nixlbench/contrib/Dockerfile

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
ARG BASE_IMAGE="nvcr.io/nvidia/cuda-dl-base"
1717
ARG 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"
2121
ARG 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
2328
RUN 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+
3780
WORKDIR /workspace
3881
RUN 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"
72113
RUN 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; \

benchmark/nixlbench/contrib/build.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
SOURCE_DIR=$(dirname "$(readlink -f "$0")")
1919
BUILD_CONTEXT=$(dirname "$(readlink -f "$SOURCE_DIR")")
2020
BUILD_CONTEXT_ARGS=""
21-
NIXL_BUILD_CONTEXT_ARGS=""
21+
NIXL_SRC=$(readlink -f "${SOURCE_DIR}/../../..")
22+
NIXL_BUILD_CONTEXT_ARGS="--build-context nixl=$NIXL_SRC"
2223
NIXL_BENCH_BUILD_CONTEXT_ARGS="--build-context nixlbench=$BUILD_CONTEXT/"
23-
NIXL_SRC=""
2424
DOCKER_FILE="${SOURCE_DIR}/Dockerfile"
25+
UCX_SRC=""
26+
UCX_BUILD_CONTEXT_ARGS=""
2527
commit_id=$(git rev-parse --short HEAD)
2628

2729
# Get latest TAG and add COMMIT_ID for dev
@@ -63,7 +65,7 @@ get_options() {
6365
--nixl)
6466
if [ "$2" ]; then
6567
NIXL_BUILD_CONTEXT_ARGS="--build-context nixl=$2"
66-
NIXL_SRC=$2
68+
NIXL_SRC=$2
6769
shift
6870
else
6971
missing_requirement $1
@@ -97,6 +99,15 @@ get_options() {
9799
missing_requirement $1
98100
fi
99101
;;
102+
--ucx)
103+
if [ "$2" ]; then
104+
UCX_SRC=$2
105+
UCX_BUILD_CONTEXT_ARGS="--build-context ucx=$2 --build-arg UCX=custom"
106+
shift
107+
else
108+
missing_requirement $1
109+
fi
110+
;;
100111
--)
101112
shift
102113
break
@@ -118,7 +129,7 @@ get_options() {
118129
error "ERROR: --nixl <path to nixl source> is required"
119130
fi
120131

121-
BUILD_CONTEXT_ARGS="$NIXL_BUILD_CONTEXT_ARGS $NIXL_BENCH_BUILD_CONTEXT_ARGS"
132+
BUILD_CONTEXT_ARGS="$NIXL_BUILD_CONTEXT_ARGS $NIXL_BENCH_BUILD_CONTEXT_ARGS $UCX_BUILD_CONTEXT_ARGS"
122133

123134
VERSION=v$latest_tag.dev.$commit_id
124135
if [ -z "$TAG" ]; then
@@ -131,6 +142,7 @@ show_build_options() {
131142
echo ""
132143
echo "Building NIXLBench Image"
133144
echo "NIXL Source: ${NIXL_SRC}"
145+
echo "UCX Source: ${UCX_SRC} (optional)"
134146
echo "Image Tag: ${TAG}"
135147
echo "Build Context: ${BUILD_CONTEXT}"
136148
echo "Build Context Args: ${BUILD_CONTEXT_ARGS}"
@@ -144,6 +156,7 @@ show_help() {
144156
echo " [--base base image]"
145157
echo " [--base-image-tag base image tag]"
146158
echo " [--nixlbench path/to/nixlbench/source/dir]"
159+
echo " [--ucx path/to/ucx/source/dir]"
147160
echo " [--no-cache disable docker build cache]"
148161
echo " [--os [ubuntu24|ubuntu22] to select Ubuntu version]"
149162
echo " [--python-versions python versions to build for, comma separated]"

0 commit comments

Comments
 (0)