@@ -167,23 +167,41 @@ RUN wget --tries=3 --waitretry=5 --timeout=30 --read-timeout=60 \
167167 make install && \
168168 ldconfig
169169
170+ # By default, uv downloads python packages to $HOME/.cache/uv and hard links them
171+ # from the virtual environment. This means that the files reside in /root/.cache/uv,
172+ # which is not what we want since some systems mount user home dir into /root,
173+ # in which case the venv is broken when the container is started.
174+ # Set a custom cache directory inside /workspace to avoid this.
175+ ENV UV_CACHE_DIR=/workspace/.cache/uv
176+ RUN mkdir -p $UV_CACHE_DIR
177+ # Disable build isolation, i.e. uv should not create a new virtual environment for
178+ # building wheels. This is faster as it skips installing dependencies twice.
179+ ENV UV_NO_BUILD_ISOLATION=1
180+ # Disable syncing, i.e. uv will not download packages outside uv pip commands.
181+ ENV UV_NO_SYNC=1
182+ # Create a new virtual environment
183+ ENV VIRTUAL_ENV=/workspace/.venv
184+ RUN rm -rf $VIRTUAL_ENV && uv venv $VIRTUAL_ENV --python $DEFAULT_PYTHON_VERSION
185+ # Activate the virtual environment
186+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
187+ # Install python dependencies
188+ RUN uv pip install --upgrade meson meson-python pybind11 patchelf pyYAML click tabulate auditwheel tomlkit
189+ # Install PyTorch
190+ RUN export UV_INDEX="https://download.pytorch.org/whl/cu$(echo $CUDA_VERSION | cut -d. -f1,2 | tr -d .)" && \
191+ uv pip install torch torchvision torchaudio
192+
170193WORKDIR /workspace/nixl
171194COPY . /workspace/nixl
172195
173196ENV LD_LIBRARY_PATH=/usr/local/lib:$LIBFABRIC_INSTALL_PATH/lib:$LD_LIBRARY_PATH
174197
175- ENV VIRTUAL_ENV=/workspace/nixl/.venv
176- RUN rm -rf $VIRTUAL_ENV && uv venv $VIRTUAL_ENV --python $DEFAULT_PYTHON_VERSION && \
177- # pybind11 pip install needed for ubuntu 22.04
178- uv pip install --upgrade "meson>=0.64.0" pybind11 patchelf
179-
180198# Install pybind11 via apt
181199RUN apt-get update && apt-get install -y --no-install-recommends pybind11-dev
182200
183201ENV NIXL_PREFIX=$NIXL_PREFIX
184202RUN rm -rf build && \
185203 mkdir build && \
186- uv run meson setup -Dlibfabric_path=$LIBFABRIC_INSTALL_PATH build/ --prefix=$NIXL_PREFIX && \
204+ meson setup -Dlibfabric_path=$LIBFABRIC_INSTALL_PATH build/ --prefix=$NIXL_PREFIX && \
187205 cd build && \
188206 ninja && \
189207 ninja install
@@ -195,11 +213,13 @@ RUN echo "$NIXL_PREFIX/lib/$ARCH-linux-gnu" > /etc/ld.so.conf.d/nixl.conf && \
195213RUN cd src/bindings/rust && cargo build --release --locked
196214
197215# Build wheel using the build-wheel.sh script for better UCX plugin bundling and library management
198- RUN ./contrib/build-wheel.sh \
216+ RUN export PATH=$VIRTUAL_ENV/bin:$PATH && \
217+ mkdir -p dist && \
218+ ./contrib/build-wheel.sh \
199219 --python-version $DEFAULT_PYTHON_VERSION \
200220 --platform manylinux_2_39_$ARCH \
201221 --ucx-plugins-dir $UCX_PLUGIN_DIR \
202222 --nixl-plugins-dir $NIXL_PLUGIN_DIR \
203223 --output-dir /workspace/nixl/dist
204224
205- RUN uv pip install dist/nixl- *cp${DEFAULT_PYTHON_VERSION//./}*.whl
225+ RUN uv pip install dist/nixl*cp${DEFAULT_PYTHON_VERSION//./}*.whl
0 commit comments