Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 32 additions & 122 deletions contrib/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,144 +13,54 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ARG BASE_IMAGE="nvcr.io/nvidia/pytorch"
ARG BASE_IMAGE_TAG="25.02-py3"
ARG BASE_IMAGE="nvcr.io/nvidia/cuda-dl-base"
ARG BASE_IMAGE_TAG="25.03-cuda12.8-devel-ubuntu24.04"

FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG}

ARG MOFED_VERSION=24.10-1.1.4.0
ARG UBUNTUOS=24.04

ENV TZ=America
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ARG NSYS_URL=https://developer.nvidia.com/downloads/assets/tools/secure/nsight-systems/2025_1/
ARG NSYS_PKG=NsightSystems-linux-cli-public-2025.1.1.131-3554042.deb

ARG NIXL_COMMIT
ARG NIXL_REPO
ARG DEFAULT_PYTHON_VERSION="3.12"

RUN apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get -y install curl \
git \
libnuma-dev \
numactl \
wget \
autotools-dev \
automake \
libtool \
libz-dev \
libiberty-dev \
flex \
build-essential \
cmake \
libibverbs-dev \
libgoogle-glog-dev \
libgtest-dev \
libjsoncpp-dev \
libpython3-dev \
libboost-all-dev \
libssl-dev \
libgrpc-dev \
libgrpc++-dev \
libprotobuf-dev \
protobuf-compiler-grpc \
DEBIAN_FRONTEND=noninteractive apt-get -y install \
ninja-build \
pybind11-dev \
python3-full \
python3-pip \
python3-numpy \
etcd-server \
net-tools \
pciutils \
libpci-dev \
vim \
tmux \
screen \
ibverbs-utils \
libibmad-dev \
googletest

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y linux-tools-common linux-tools-generic ethtool iproute2
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y dkms linux-headers-generic
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y meson ninja-build uuid-dev gdb

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt install -y wget libglib2.0-0
RUN wget ${NSYS_URL}${NSYS_PKG} && dpkg -i $NSYS_PKG && rm $NSYS_PKG

RUN cd /usr/local/src && \
curl -fSsL "https://content.mellanox.com/ofed/MLNX_OFED-${MOFED_VERSION}/MLNX_OFED_LINUX-${MOFED_VERSION}-ubuntu${UBUNTUOS}-x86_64.tgz" -o mofed.tgz && \
tar -xf /usr/local/src/mofed.tgz && \
cd MLNX_OFED_LINUX-* && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
./DEBS/libibverbs* ./DEBS/ibverbs-providers* ./DEBS/librdmacm* ./DEBS/libibumad* && \
rm -rf /var/lib/apt/lists/* /usr/local/src/*

ENV LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64 \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs

ENV LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
cmake
Comment thread
nv-anants marked this conversation as resolved.
Resolved

WORKDIR /workspace
RUN git clone https://github.com/NVIDIA/gdrcopy.git
RUN PREFIX=/usr/local DESTLIB=/usr/local/lib make -C /workspace/gdrcopy lib_install
RUN cp gdrcopy/src/libgdrapi.so.2.* /usr/lib/x86_64-linux-gnu/
RUN ldconfig

ARG UCX_VERSION=v1.18.0

RUN cd /usr/local/src && \
curl -fSsL "https://github.com/openucx/ucx/tarball/${UCX_VERSION}" | tar xz && \
cd openucx-ucx* && \
./autogen.sh && ./configure \
--enable-shared \
--disable-static \
--disable-doxygen-doc \
--enable-optimizations \
--enable-cma \
--enable-devel-headers \
--with-cuda=/usr/local/cuda \
--with-verbs \
--with-dm \
--with-gdrcopy=/usr/local \
--enable-mt && \
make -j && \
make -j install-strip && \
ldconfig
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

ENV LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
ENV CPATH=/usr/include:$CPATH
ENV PATH=/usr/bin:$PATH
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
SHELL ["/bin/bash", "-c"]
WORKDIR /workspace/nixl

# LD_LIBRARY_PATH is needed for auditwheel to find libcuda.so.1
# Set incorrectly to `compat/lib` in cuda-dl-base image
ENV LD_LIBRARY_PATH=/usr/local/cuda/compat/lib.real:$LD_LIBRARY_PATH
ENV LD_LIBRARY_PATH=/usr/local/nixl/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
ENV PYTHONPATH=/usr/local/nixl/lib/python3/dist-packages/:$PYTHONPATH

# Required for Ubuntu 22.04
RUN pip3 install --upgrade meson torch
ENV VIRTUAL_ENV=/workspace/nixl/.venv
RUN uv venv $VIRTUAL_ENV --python $DEFAULT_PYTHON_VERSION && \
# pybind11 pip install needed for ubuntu 22.04
uv pip install --upgrade meson pybind11 patchelf

# Make sure to build the container from the cloned git repository
WORKDIR /opt/nixl
COPY --from=nixl . .
RUN echo "NIXL commit: ${NIXL_COMMIT}" > /opt/nixl/commit.txt
RUN cd /opt/nixl && \
COPY . /workspace/nixl
Comment thread
tstamler marked this conversation as resolved.
Resolved

RUN rm -rf build && \
mkdir build && \
meson setup build/ --prefix=/usr/local/nixl && \
cd build/ && \
uv run meson setup build/ --prefix=/usr/local/nixl && \
cd build && \
ninja && \
ninja install

RUN echo "/usr/local/nixl/lib/x86_64-linux-gnu" > /etc/ld.so.conf.d/nixl.conf
RUN echo "/usr/local/nixl/lib/x86_64-linux-gnu/plugins" >> /etc/ld.so.conf.d/nixl.conf
ENV NIXL_PLUGIN_DIR=/usr/local/nixl/lib/x86_64-linux-gnu/plugins
RUN ldconfig
RUN echo "/usr/local/nixl/lib/x86_64-linux-gnu" > /etc/ld.so.conf.d/nixl.conf && \
echo "/usr/local/nixl/lib/x86_64-linux-gnu/plugins" >> /etc/ld.so.conf.d/nixl.conf && \
ldconfig

# Create the wheel
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN pip3 install patchelf auditwheel
RUN cd /opt/nixl && uv build --wheel --out-dir /workspace/dist
RUN auditwheel repair /workspace/dist/nixl-*cp31*.whl --plat manylinux_2_39_x86_64
ARG WHL_PYTHON_VERSIONS="3.12"
ARG WHL_PLATFORM="manylinux_2_39_x86_64"
RUN IFS=',' read -ra PYTHON_VERSIONS <<< "$WHL_PYTHON_VERSIONS" && \
for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}"; do \
uv build --wheel --out-dir /tmp/dist --python $PYTHON_VERSION; \
done
RUN uv pip install auditwheel && \
uv run auditwheel repair /tmp/dist/nixl-*cp31*.whl --plat $WHL_PLATFORM --wheel-dir /workspace/nixl/dist

RUN uv pip install dist/nixl-*cp${DEFAULT_PYTHON_VERSION//./}*.whl
Comment thread
nv-anants marked this conversation as resolved.
Resolved
105 changes: 44 additions & 61 deletions contrib/build-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,21 @@
SOURCE_DIR=$(dirname "$(readlink -f "$0")")
BUILD_CONTEXT=$(dirname "$(readlink -f "$SOURCE_DIR")")
DOCKER_FILE="${SOURCE_DIR}/Dockerfile"

commit_id=$(git rev-parse --short HEAD)
FULLCOMMIT=$(git rev-parse HEAD)

# Get latest TAG and add COMMIT_ID for dev
latest_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1 main) | sed 's/^v//') || true
if [[ -z ${latest_tag} ]]; then
latest_tag="0.0.1"
echo "No git release tag found, setting to unknown version: ${latest_tag}"
fi

BASE_IMAGE=nvcr.io/nvidia/pytorch
BASE_IMAGE_TAG=25.02-py3
VERSION=v$latest_tag.dev.$commit_id
UBUNTUOS="24.04"
USE_LOCAL_DIR=0
NIXL_DIR=/tmp/nixl

NIXL_COMMIT=ec6345c5279142a3805ab1a0e876f954d079dbf7
NIXL_REPO=ai-dynamo/nixl.git
BASE_IMAGE=nvcr.io/nvidia/cuda-dl-base
BASE_IMAGE_TAG=25.03-cuda12.8-devel-ubuntu24.04
WHL_PLATFORM=manylinux_2_39_x86_64
WHL_PYTHON_VERSIONS="3.12"
OS="ubuntu24"

get_options() {
while :; do
Expand All @@ -47,24 +42,24 @@ get_options() {
exit
;;
--base-image)
if [ "$2" ]; then
BASE_IMAGE="$2"
shift
else
missing_requirement $1
fi
;;
--base-imge-tag)
if [ "$2" ]; then
BASE_IMAGE="$2"
shift
else
missing_requirement $1
fi
;;
--base-image-tag)
if [ "$2" ]; then
BASE_IMAGE_TAG=$2
shift
else
missing_requirement $1
fi
;;
--os)
--os)
if [ "$2" ]; then
UBUNTUOS=$2
OS=$2
shift
else
missing_requirement $1
Expand All @@ -81,9 +76,14 @@ get_options() {
missing_requirement $1
fi
;;
--use-local)
USE_LOCAL_DIR=1
;;
--python-versions)
if [ "$2" ]; then
WHL_PYTHON_VERSIONS=$2
shift
else
missing_requirement $1
fi
;;
--)
shift
break
Expand All @@ -101,36 +101,34 @@ get_options() {
shift
done

if [[ $UBUNTUOS == "22.04" ]]; then
BASE_IMAGE=nvcr.io/nvidia/cuda-dl-base
BASE_IMAGE_TAG=24.10-cuda12.6-devel-ubuntu22.04
if [[ $OS == "ubuntu22" ]]; then
BASE_IMAGE_TAG=24.10-cuda12.6-devel-ubuntu22.04
WHL_PLATFORM=manylinux_2_34_x86_64
fi

if [ -z "$TAG" ]; then
TAG="--tag nixl:${VERSION}"
fi

if [ $USE_LOCAL_DIR -eq 1 ]; then
NIXL_DIR=$BUILD_CONTEXT
NIXL_COMMIT=$FULLCOMMIT
fi
}

show_build_options() {
echo ""
echo "Building NIXL Image: '${TAG}' for Ubuntu${UBUNTUOS}"
echo "Using local nixl source: ${NIXL_DIR}"
echo " Build Context: ${BUILD_CONTEXT}"
echo "Building NIXL Image"
echo "Image Tag: ${TAG}"
echo "Build Context: ${BUILD_CONTEXT}"
echo "Base Image: ${BASE_IMAGE}:${BASE_IMAGE_TAG}"
echo "Python Versions for wheel build: ${WHL_PYTHON_VERSIONS}"
echo "Wheel Platform: ${WHL_PLATFORM}"
}

show_help() {
echo "usage: build.sh"
echo "usage: build-container.sh"
echo " [--base base image]"
echo " [--base-imge-tag base image tag]"
echo " [--base-image-tag base image tag]"
echo " [--no-cache disable docker build cache]"
echo " [--os [24.04|22.04] to select Ubuntu version]"
echo " [--os [ubuntu24|ubuntu22] to select Ubuntu version]"
echo " [--tag tag for image]"
echo " [--use-local copy current source dir to container]"
echo " [--python-versions python versions to build for, comma separated]"
exit 0
}

Expand All @@ -145,30 +143,15 @@ error() {

get_options "$@"

show_build_options

if [ $USE_LOCAL_DIR -eq 0 ]; then
if [ -d "$NIXL_DIR" ]; then
echo "Warning: $NIXL_DIR exists, skipping clone"
else
git clone https://github.com/${NIXL_REPO} ${NIXL_DIR}
fi

if ! git checkout ${NIXL_COMMIT}; then
echo "ERROR: Failed to checkout commit ${NIXL_COMMIT}."
echo "Please delete $NIXL_DIR and retry."
exit 1
fi
else
if [ -d "$NIXL_DIR/build" ]; then
echo "Please delete the build directory before creating container"
exit 1
fi
if [ -d "$NIXL_DIR/build" ]; then
echo "Please delete the build directory before creating container"
exit 1
fi

BUILD_CONTEXT_ARGS+=" --build-context nixl=$NIXL_DIR"
BUILD_ARGS+=" --build-arg NIXL_COMMIT=${NIXL_COMMIT} --build-arg NIXL_REPO=${NIXL_REPO}"
BUILD_ARGS+=" --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg BASE_IMAGE_TAG=$BASE_IMAGE_TAG"
BUILD_ARGS+=" --build-arg UBUNTUOS=$UBUNTUOS"
BUILD_ARGS+=" --build-arg WHL_PYTHON_VERSIONS=$WHL_PYTHON_VERSIONS"
BUILD_ARGS+=" --build-arg WHL_PLATFORM=$WHL_PLATFORM"

show_build_options

docker build -f $DOCKER_FILE $BUILD_ARGS $TAG $NO_CACHE $BUILD_CONTEXT_ARGS $BUILD_CONTEXT
docker build -f $DOCKER_FILE $BUILD_ARGS $TAG $NO_CACHE $BUILD_ARGS $BUILD_CONTEXT
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if ucx_path != ''
link_args : ['-L' + ucx_lib_path, '-lucp', '-lucs', '-luct'],
include_directories : include_directories(ucx_inc_path))
else
ucx_dep = dependency('ucx')
ucx_dep = dependency('ucx', modules: ['ucx::ucs', 'ucx::ucp', 'ucx::uct'])
endif

if get_option('disable_gds_backend')
Expand Down