## Summary - Remove `prime` (the Prime CLI) from prime-rl's runtime dependencies. No prime-rl code imports `prime_cli`. The CLI only tied prime-rl's lock to the CLI's releases, and gave `prime-sandboxes` a second path into the lock next to `verifiers`. - `Dockerfile.cuda`: install the CLI as a uv tool in its own venv (`/opt/uv-tools`, executable in `/usr/local/bin`), pinned by `ARG PRIME_CLI_VERSION=0.19.2`. The platform keeps running `uv run --no-sync prime env install '<id>'` unchanged. Since prime CLI 0.8.0, `prime env install` installs into `$UV_PROJECT_ENVIRONMENT`, `$VIRTUAL_ENV`, or the `.venv` next to the nearest `pyproject.toml`, so Hub envs still land in `/app/.venv`. - `scripts/install.sh`: run `uv tool install prime` for local use. The docs already tell users to install the CLI this way. - `uv.lock` drops `prime`, `prime-evals` and `gitignore-parser`. `pyproject.toml` drops their now-unused `exclude-newer-package` entries. Source overlays on older images keep working: the entrypoint syncs with `--inexact`, so the CLI already in those images' `/app/.venv` stays in place. ## Breaking - `uv sync` no longer installs the `prime` command into the project venv, so `uv run prime …` in a prime-rl checkout fails until the CLI is installed. Migration: run `uv tool install prime`, then call `prime …` directly. ## Verification - Local check, `prime==0.19.2` installed with `uv tool install` and absent from the target project venv: `uv run --no-sync prime env install primeintellect/gsm8k` installed `gsm8k` into the project `.venv` and not into the tool venv. A plain `prime env install` from the project root did the same. - Hosted e2e: pending (reverse-text from the Hub with `prime train`, on an image built from this branch). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Packaging and install-path changes only; runtime training code is untouched, with a documented migration for local CLI usage. > > **Overview** > **Removes the `prime` CLI from prime-rl’s Python dependencies and lockfile**, so CLI releases no longer force lock updates and transitive packages like `prime-evals` and `gitignore-parser` drop out of `uv.lock`. > > **Docker and local setup now install the CLI separately** via `uv tool install`: the CUDA image pins `PRIME_CLI_VERSION=0.19.2` into `/opt/uv-tools` with `prime` on `PATH`, and `scripts/install.sh` runs the same after `uv sync`. Hub env installs (`prime env install` / `uv run --no-sync prime env install`) are unchanged in intent—the CLI still targets the project `.venv`, not the tool venv. > > **Breaking for devs:** `uv sync` no longer puts `prime` in the project venv, so **`uv run prime …` fails until you run `uv tool install prime`** and invoke `prime` directly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 82cac44caaa77bd77c1b2796186e74264068b873. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
294 lines
13 KiB
Docker
294 lines
13 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
ARG DEPENDENCY_IMAGE=dependencies
|
|
|
|
FROM ghcr.io/astral-sh/uv:0.11.9@sha256:6b6fa841d71a48fbc9e2c55651c5ad570e01104d7a7d701f57b2b22c0f58e9b1 AS uv
|
|
|
|
FROM ubuntu:24.04@sha256:a853f94d226358a79c740cfc7bce0c289748f3fe3488d921d038ccd752c61b60 AS python-builder
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates python3.12 python3.12-venv \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
COPY --from=uv /uv /uvx /usr/local/bin/
|
|
ENV UV_PYTHON_PREFERENCE=only-system UV_LINK_MODE=copy
|
|
|
|
# Every pyproject.toml + uv.lock, so the dependency sync below caches
|
|
# independently of source edits.
|
|
FROM python-builder AS manifests
|
|
COPY . /ctx
|
|
RUN mkdir -p /manifests \
|
|
&& cd /ctx \
|
|
&& find . -name .git -prune -o -type f -name pyproject.toml -exec cp --parents {} /manifests/ \; \
|
|
&& cp uv.lock /manifests/
|
|
|
|
# Build stage - multi-arch base (supports amd64 + arm64)
|
|
FROM nvidia/cuda:13.0.1-cudnn-devel-ubuntu24.04@sha256:8b2705ea7a8653ad3451b46ab835eced92d77b44e671b9cf3ad4f95fbb2efe5e AS builder
|
|
LABEL maintainer="prime intellect"
|
|
LABEL repository="prime-rl"
|
|
|
|
# Set en_US.UTF-8 locale by default
|
|
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment
|
|
|
|
# Set CUDA_HOME and update PATH
|
|
ENV CUDA_HOME=/usr/local/cuda
|
|
ENV PATH=$PATH:/usr/local/cuda/bin
|
|
|
|
# Install build tooling.
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=Etc/UTC
|
|
RUN apt-get update && apt-get install -y --no-install-recommends --force-yes \
|
|
build-essential \
|
|
autoconf \
|
|
automake \
|
|
libtool \
|
|
pkg-config \
|
|
ca-certificates \
|
|
curl \
|
|
sudo \
|
|
git \
|
|
ninja-build \
|
|
libnuma-dev \
|
|
libnl-3-dev \
|
|
libnl-route-3-dev \
|
|
libibverbs-dev \
|
|
librdmacm-dev \
|
|
python3.12 \
|
|
python3.12-venv \
|
|
python3.12-dev \
|
|
&& ln -sf /usr/bin/python3.12 /usr/local/bin/python \
|
|
&& apt-get clean autoclean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
|
|
|
ARG UCX_VERSION=1.19.1
|
|
RUN git clone --depth 1 --branch v${UCX_VERSION} https://github.com/openucx/ucx.git /tmp/ucx \
|
|
&& cd /tmp/ucx \
|
|
&& ./autogen.sh \
|
|
&& ./configure \
|
|
--prefix=/opt/ucx \
|
|
--enable-shared \
|
|
--disable-static \
|
|
--disable-doxygen-doc \
|
|
--enable-optimizations \
|
|
--enable-cma \
|
|
--enable-devel-headers \
|
|
--enable-mt \
|
|
--with-verbs \
|
|
--with-cuda=/usr/local/cuda \
|
|
--with-ze=no \
|
|
&& make -j"$(nproc)" \
|
|
&& make install \
|
|
&& rm -rf /tmp/ucx
|
|
|
|
COPY --from=uv /uv /uvx /usr/local/bin/
|
|
ENV PATH="/usr/local/bin:$PATH"
|
|
# Build .venv against the system CPython, so the venv's recorded interpreter
|
|
# matches the runtime interpreter and no bin/python relink is needed at runtime.
|
|
ENV UV_PYTHON_PREFERENCE=only-system
|
|
ENV UV_CACHE_DIR="/usr/local/share/uv/cache"
|
|
ENV UV_PROJECT_ENVIRONMENT="/app/.venv"
|
|
|
|
# Install Python dependencies
|
|
WORKDIR /app
|
|
|
|
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
|
|
|
# The runtime dependency image contains no first-party source or editable installs.
|
|
COPY --from=manifests /manifests /app
|
|
RUN --mount=type=cache,target=/usr/local/share/uv/cache \
|
|
uv sync --all-packages --extra gpu --extra dashboard --extra flash-attn --extra flash-attn-3 --extra flash-attn-cute --extra disagg --extra quack --extra kernels --locked --no-dev \
|
|
--no-install-local
|
|
|
|
# Build NIXL from source against the UCX 1.19 baked above. The PyPI nixl wheel
|
|
# ships its own UCX which segfaults on prefill→decode KV transfer (#2883);
|
|
# rebuilding against our UCX is the documented fix. The rename is required: an
|
|
# unrenamed source build is `nixl_cu12`, and the `nixl` shim imports nixl_cu13
|
|
# (the PyPI wheel) first, so the fix would silently not apply. Libraries carry
|
|
# RUNPATH=/opt/ucx/lib, so no LD_LIBRARY_PATH is needed at runtime.
|
|
# Opt out via `--build-arg INCLUDE_NIXL_FROM_SOURCE=0`.
|
|
#
|
|
# NIXL's [build-system] requires are unpinned, so pip's build isolation picks up
|
|
# new backends as they are released. meson-python 0.22.0 stopped keeping Meson's
|
|
# build RPATH in wheel libraries, which dropped RUNPATH=/opt/ucx/lib and failed
|
|
# the linkage check below on every build. Pin the validated backend.
|
|
ARG INCLUDE_NIXL_FROM_SOURCE=1
|
|
ARG NIXL_VERSION=0.10.1
|
|
RUN if [ "$INCLUDE_NIXL_FROM_SOURCE" = "1" ]; then \
|
|
VIRTUAL_ENV=/app/.venv uv pip install pip \
|
|
&& git clone --depth 1 --branch ${NIXL_VERSION} https://github.com/ai-dynamo/nixl.git /tmp/nixl \
|
|
&& cd /tmp/nixl \
|
|
&& uv run --no-project --with tomlkit python contrib/tomlutil.py --wheel-name nixl-cu13 pyproject.toml \
|
|
&& printf 'meson-python==0.21.1\n' > /tmp/nixl-build-constraints.txt \
|
|
&& PKG_CONFIG_PATH=/opt/ucx/lib/pkgconfig \
|
|
/app/.venv/bin/python -m pip wheel . --no-deps --wheel-dir=/tmp/nixl-whl \
|
|
--build-constraint /tmp/nixl-build-constraints.txt \
|
|
&& VIRTUAL_ENV=/app/.venv uv pip install --reinstall --no-deps /tmp/nixl-whl/nixl_cu13-*.whl \
|
|
&& PLUGIN=/app/.venv/lib/python3.12/site-packages/.nixl_cu13.mesonpy.libs/plugins/libplugin_UCX.so \
|
|
&& if ! ldd "$PLUGIN" | grep -q /opt/ucx/lib/libucp.so; then \
|
|
echo "ERROR: $PLUGIN does not link /opt/ucx/lib. RUNPATH and ldd output:" >&2; \
|
|
readelf -d "$PLUGIN" | grep -E 'RUNPATH|RPATH' >&2 || true; \
|
|
ldd "$PLUGIN" >&2; \
|
|
exit 1; \
|
|
fi \
|
|
&& rm -rf /tmp/nixl /tmp/nixl-whl /tmp/nixl-build-constraints.txt; \
|
|
fi
|
|
|
|
# Trim the CUDA toolkit to the nvcc-JIT essentials in a separate stage, so the runtime
|
|
# COPY ships only the trimmed result (~1.5 GB) instead of the full ~6.6 GB. Drops the math
|
|
# runtime libs (cublas/cusparse/cufft/cusolver/curand/npp/nvjpeg) and big static .a
|
|
# archives since nvcc JIT (TileLang/FlashInfer build their own kernels) and torch
|
|
# (uses pinned nvidia-* wheels) needs them. Keeps nvcc/nvvm/ptxas + headers +
|
|
# libcudart/libnvrtc/libcudadevrt for JIT compile+link.
|
|
FROM builder AS cuda-trim
|
|
RUN find /usr/local/cuda-13.0/targets/*/lib \
|
|
\( -name 'libcublas*' -o -name 'libcusparse*' -o -name 'libcufft*' \
|
|
-o -name 'libcusolver*' -o -name 'libcurand*' -o -name 'libnpp*' \
|
|
-o -name 'libnvjpeg*' -o -name 'libnvblas*' \) -delete \
|
|
&& find /usr/local/cuda-13.0 -name '*.a' ! -name 'libcudadevrt.a' ! -name 'libcudart_static.a' -delete
|
|
|
|
# Runtime image
|
|
FROM nvidia/cuda:13.0.1-base-ubuntu24.04@sha256:f8ef28f579ea42a44b415d2c5d46f788e6a9b395c6c83f2929416e1fc192c143 AS dependencies
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
--no-install-recommends \
|
|
--force-yes \
|
|
python3.12 \
|
|
python3.12-venv \
|
|
python3.12-dev \
|
|
build-essential \
|
|
wget \
|
|
clang \
|
|
tmux \
|
|
iperf \
|
|
openssh-server \
|
|
git \
|
|
git-lfs \
|
|
gpg \
|
|
sudo \
|
|
iputils-ping \
|
|
net-tools \
|
|
curl \
|
|
vim \
|
|
libnuma1 \
|
|
libnl-3-200 \
|
|
libnl-route-3-200 \
|
|
libibverbs1 \
|
|
ibverbs-providers \
|
|
librdmacm1 \
|
|
libhwloc15 \
|
|
&& ln -sf /usr/bin/python3.12 /usr/local/bin/python \
|
|
&& apt-get clean autoclean \
|
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
|
|
|
# AWS EFA userspace stack: libfabric + the aws-ofi-nccl NCCL net plugin,
|
|
# installed as one version-matched unit via AWS's official installer rather
|
|
# than picking versions by hand. Do not substitute a host-mounted copy of
|
|
# these libraries instead of building them in -- symbol-version mismatches
|
|
# between a host's rdma-core and a container's can silently break the NCCL
|
|
# plugin. Run directly in this stage (not a separate one COPY'd in after):
|
|
# the installer's own apt-get/dpkg step upgrades system rdma-core packages
|
|
# (libibverbs, ibverbs-providers, librdmacm) in place to versions libfabric
|
|
# actually links against -- copying only /opt/amazon out of an isolated
|
|
# stage leaves that system-wide upgrade behind, so libfabric ends up paired
|
|
# with whatever older rdma-core this image's own apt install pulled in and
|
|
# fails to load (symbol version mismatch on libefa.so.1). --skip-kmod:
|
|
# containers share the host kernel and must never build/load a kernel
|
|
# module themselves; the EFA driver is expected to already be present on
|
|
# the host. --skip-limit-conf: ulimits config doesn't apply inside a build.
|
|
ARG EFA_INSTALLER_VERSION=1.47.0
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates tar gzip \
|
|
&& curl -fsSL "https://efa-installer.amazonaws.com/aws-efa-installer-${EFA_INSTALLER_VERSION}.tar.gz" \
|
|
-o /tmp/aws-efa-installer.tar.gz \
|
|
&& tar -xzf /tmp/aws-efa-installer.tar.gz -C /tmp \
|
|
&& cd /tmp/aws-efa-installer \
|
|
&& ./efa_installer.sh -y --skip-kmod --skip-limit-conf \
|
|
&& cd / && rm -rf /tmp/aws-efa-installer.tar.gz /tmp/aws-efa-installer \
|
|
&& apt-get clean autoclean && rm -rf /var/lib/apt/lists/*
|
|
|
|
# CUDA 13.0 toolkit (TileLang's runtime nvcc JIT)
|
|
COPY --from=cuda-trim /usr/local/cuda-13.0 /usr/local/cuda-13.0
|
|
RUN ln -sfn /usr/local/cuda-13.0 /usr/local/cuda && test -x /usr/local/cuda/bin/nvcc
|
|
ENV CUDA_HOME=/usr/local/cuda
|
|
ENV PATH="/usr/local/cuda/bin:${PATH}"
|
|
|
|
ARG USER_ID=1000
|
|
ARG GROUP_ID=1000
|
|
|
|
RUN userdel -r ubuntu 2>/dev/null || true; \
|
|
groupdel ubuntu 2>/dev/null || true; \
|
|
groupadd --gid $GROUP_ID appuser && \
|
|
useradd --uid $USER_ID --gid appuser --create-home --shell /bin/bash appuser && \
|
|
usermod -aG sudo appuser && \
|
|
echo "appuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
|
|
# Install uv for development use
|
|
COPY --from=uv /uv /uvx /usr/local/bin/
|
|
|
|
# The platform installs Hub environments with `uv run --no-sync prime env install`.
|
|
# The CLI gets its own tool venv so its dependencies stay out of prime-rl's lock;
|
|
# `prime env install` still installs into the project venv (/app/.venv).
|
|
ARG PRIME_CLI_VERSION=0.19.2
|
|
RUN UV_TOOL_DIR=/opt/uv-tools UV_TOOL_BIN_DIR=/usr/local/bin \
|
|
uv tool install --no-cache --python /usr/bin/python3.12 "prime==${PRIME_CLI_VERSION}" \
|
|
&& prime --version
|
|
|
|
USER appuser
|
|
ENV PATH="/usr/local/bin:$PATH"
|
|
WORKDIR /app
|
|
# Split the largest dependency trees so compression and pulls can run in parallel.
|
|
COPY --from=builder --chown=appuser:appuser /app/.venv/lib/python3.12/site-packages/nvidia /app/.venv/lib/python3.12/site-packages/nvidia
|
|
COPY --from=builder --chown=appuser:appuser /app/.venv/lib/python3.12/site-packages/torch /app/.venv/lib/python3.12/site-packages/torch
|
|
COPY --from=builder --chown=appuser:appuser /app/.venv/lib/python3.12/site-packages/vllm /app/.venv/lib/python3.12/site-packages/vllm
|
|
COPY --from=builder --chown=appuser:appuser /app/.venv/lib/python3.12/site-packages/flash_attn /app/.venv/lib/python3.12/site-packages/flash_attn
|
|
COPY --from=builder --chown=appuser:appuser /app/.venv/lib/python3.12/site-packages/flash_attn_2_cuda*.so /app/.venv/lib/python3.12/site-packages/
|
|
COPY --from=builder /opt/ucx /opt/ucx
|
|
|
|
COPY --from=builder --chown=appuser:appuser \
|
|
--exclude=lib/python3.12/site-packages/nvidia \
|
|
--exclude=lib/python3.12/site-packages/torch \
|
|
--exclude=lib/python3.12/site-packages/vllm \
|
|
--exclude=lib/python3.12/site-packages/flash_attn \
|
|
--exclude=lib/python3.12/site-packages/flash_attn_2_cuda*.so \
|
|
/app/.venv /app/.venv
|
|
RUN /app/.venv/bin/python -c 'from importlib.metadata import version; [version(name) for name in ("deep-ep", "deep-gemm", "mamba-ssm", "nixl", "prime-kernels", "quack-kernels", "vllm", "vllm-router")]' \
|
|
&& if [ "$(uname -m)" = "x86_64" ]; then \
|
|
/app/.venv/bin/python -c 'from importlib.metadata import version; version("flash-mla")'; \
|
|
fi
|
|
|
|
# Place executables in the environment at the front of the path
|
|
ENV PATH="/app/.venv/bin:$PATH"
|
|
ENV UCX_HOME=/opt/ucx
|
|
ENV LD_LIBRARY_PATH="/opt/ucx/lib:/opt/ucx/lib/ucx${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
|
|
|
|
# HuggingFace Hub timeouts (defaults are 10s which causes issues on slow networks)
|
|
ENV HF_HUB_ETAG_TIMEOUT=500
|
|
ENV HF_HUB_DOWNLOAD_TIMEOUT=300
|
|
|
|
FROM python-builder AS application-builder
|
|
WORKDIR /app
|
|
COPY pyproject.toml uv.lock README.md /app/
|
|
COPY src /app/src
|
|
COPY packages /app/packages
|
|
COPY deps /app/deps
|
|
COPY configs /app/configs
|
|
COPY examples /app/examples
|
|
COPY scripts/docker-editable-pretend-versions.sh /app/scripts/docker-editable-pretend-versions.sh
|
|
COPY scripts/docker_application.py /build/docker_application.py
|
|
ARG VERIFIERS_PRETEND_VERSION
|
|
ARG RENDERERS_PRETEND_VERSION
|
|
ARG PYDANTIC_CONFIG_PRETEND_VERSION
|
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
eval "$(bash /app/scripts/docker-editable-pretend-versions.sh --shell /app)" \
|
|
&& uv run --no-project --python /usr/bin/python3.12 /build/docker_application.py /app /out/app
|
|
|
|
# COPY --link and numeric ownership let source builds reuse dependency blobs without unpacking them.
|
|
FROM ${DEPENDENCY_IMAGE} AS runtime
|
|
ARG USER_ID=1000
|
|
ARG GROUP_ID=1000
|
|
COPY --link --from=application-builder --chown=${USER_ID}:${GROUP_ID} /out/app /app
|
|
# Preserve the executable Git mode; --chmod disables BuildKit's linked-copy optimization.
|
|
COPY --link --chown=${USER_ID}:${GROUP_ID} scripts/docker-entrypoint.sh /app/docker-entrypoint.sh
|
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
|
CMD ["sleep", "infinity"]
|