From 52b46097894ced5caa4c12f6cc73a2c6156f074e Mon Sep 17 00:00:00 2001 From: Kangyan-Zhou Date: Mon, 4 May 2026 00:37:55 -0700 Subject: [PATCH] [Docker] Prep for torch 2.11: cu129 fix, image validator, dep cleanup (#23593) Co-authored-by: Claude Opus 4.7 (1M context) Co-authored-by: Baizhou Zhang --- .github/workflows/release-docker-dev.yml | 10 +- .github/workflows/release-docker-runtime.yml | 6 +- .github/workflows/release-docker.yml | 8 +- .github/workflows/trivy-scan-dev.yml | 2 +- docker/Dockerfile | 55 ++++----- docker/diffusion.Dockerfile | 104 ------------------ .../ci/utils/docker_build_metadata_args.py | 2 +- 7 files changed, 36 insertions(+), 151 deletions(-) delete mode 100644 docker/diffusion.Dockerfile diff --git a/.github/workflows/release-docker-dev.yml b/.github/workflows/release-docker-dev.yml index a41c57c07..4a8228106 100644 --- a/.github/workflows/release-docker-dev.yml +++ b/.github/workflows/release-docker-dev.yml @@ -56,12 +56,14 @@ jobs: SUFFIX="-pr-${{ inputs.pr_number }}" fi - # Build tag config + # Build tag config. dev-cu13 / nightly-dev-cu13 are published as + # aliases on the cu130 image for backwards compatibility with + # consumers pinned to the pre-flip names. if [ -z "${SUFFIX}" ]; then # Nightly: include dated tags - TAG_CONFIG='[{"cuda":"cu129","tags":["dev","nightly-dev-{date}-{short_sha}"]},{"cuda":"cu130","tags":["dev-cu13","nightly-dev-cu13-{date}-{short_sha}"]}]' + TAG_CONFIG='[{"cuda":"cu129","tags":["dev-cu12","nightly-dev-cu12-{date}-{short_sha}"]},{"cuda":"cu130","tags":["dev","dev-cu13","nightly-dev-{date}-{short_sha}","nightly-dev-cu13-{date}-{short_sha}"]}]' else - TAG_CONFIG="[{\"cuda\":\"cu129\",\"tags\":[\"dev${SUFFIX}\"]},{\"cuda\":\"cu130\",\"tags\":[\"dev-cu13${SUFFIX}\"]}]" + TAG_CONFIG="[{\"cuda\":\"cu129\",\"tags\":[\"dev-cu12${SUFFIX}\"]},{\"cuda\":\"cu130\",\"tags\":[\"dev${SUFFIX}\",\"dev-cu13${SUFFIX}\"]}]" fi echo "tag_config=${TAG_CONFIG}" >> $GITHUB_OUTPUT @@ -81,6 +83,6 @@ jobs: if: ${{ !inputs.tag && !inputs.pr_number }} uses: ./.github/workflows/_docker-cleanup-nightly.yml with: - tag_prefixes: '["nightly-dev", "nightly-dev-cu13"]' + tag_prefixes: '["nightly-dev", "nightly-dev-cu12", "nightly-dev-cu13"]' image_repo: ${{ inputs.image_repo || 'lmsysorg/sglang' }} secrets: inherit diff --git a/.github/workflows/release-docker-runtime.yml b/.github/workflows/release-docker-runtime.yml index b2002a627..0e224bf91 100644 --- a/.github/workflows/release-docker-runtime.yml +++ b/.github/workflows/release-docker-runtime.yml @@ -2,7 +2,7 @@ name: Release Docker Runtime Images # # Builds and publishes runtime Docker images (production-optimized, ~50% smaller): # - lmsysorg/sglang:v{version}-runtime, lmsysorg/sglang:latest-runtime -# - lmsysorg/sglang:v{version}-cu130-runtime, lmsysorg/sglang:latest-cu130-runtime +# - lmsysorg/sglang:v{version}-cu129-runtime, lmsysorg/sglang:latest-cu129-runtime # on: push: @@ -49,7 +49,7 @@ jobs: image_repo: ${{ inputs.image_repo || 'lmsysorg/sglang' }} tag_config: | [ - {"cuda": "cu129", "tags": ["v${{ needs.resolve-version.outputs.version }}-runtime", "latest-runtime"]}, - {"cuda": "cu130", "tags": ["v${{ needs.resolve-version.outputs.version }}-cu130-runtime", "latest-cu130-runtime"]} + {"cuda": "cu130", "tags": ["v${{ needs.resolve-version.outputs.version }}-runtime", "latest-runtime", "v${{ needs.resolve-version.outputs.version }}-cu130-runtime", "latest-cu130-runtime"]}, + {"cuda": "cu129", "tags": ["v${{ needs.resolve-version.outputs.version }}-cu129-runtime", "latest-cu129-runtime"]} ] secrets: inherit diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 71c2644ec..edf21469e 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -1,8 +1,8 @@ name: Release Docker Images # # Builds and publishes framework Docker images (full development environment): -# - lmsysorg/sglang:v{version}, lmsysorg/sglang:latest -# - lmsysorg/sglang:v{version}-cu130, lmsysorg/sglang:latest-cu130 +# - lmsysorg/sglang:v{version}, lmsysorg/sglang:latest (cuda 13) +# - lmsysorg/sglang:v{version}-cu129, lmsysorg/sglang:latest-cu129 # on: push: @@ -49,7 +49,7 @@ jobs: image_repo: ${{ inputs.image_repo || 'lmsysorg/sglang' }} tag_config: | [ - {"cuda": "cu129", "tags": ["v${{ needs.resolve-version.outputs.version }}", "latest"]}, - {"cuda": "cu130", "tags": ["v${{ needs.resolve-version.outputs.version }}-cu130", "latest-cu130"]} + {"cuda": "cu130", "tags": ["v${{ needs.resolve-version.outputs.version }}", "latest", "v${{ needs.resolve-version.outputs.version }}-cu130", "latest-cu130"]}, + {"cuda": "cu129", "tags": ["v${{ needs.resolve-version.outputs.version }}-cu129", "latest-cu129"]} ] secrets: inherit diff --git a/.github/workflows/trivy-scan-dev.yml b/.github/workflows/trivy-scan-dev.yml index ab315cab6..f35476597 100644 --- a/.github/workflows/trivy-scan-dev.yml +++ b/.github/workflows/trivy-scan-dev.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - tag: ${{ inputs.tag && fromJSON(format('["{0}"]', inputs.tag)) || fromJSON('["dev", "dev-cu13"]') }} + tag: ${{ inputs.tag && fromJSON(format('["{0}"]', inputs.tag)) || fromJSON('["dev", "dev-cu12"]') }} steps: - name: Cleanup workspace (remove root-owned files from prior runs) run: sudo rm -rf "$GITHUB_WORKSPACE"/* || true diff --git a/docker/Dockerfile b/docker/Dockerfile index 2572eb1b7..949e2530a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -ARG CUDA_VERSION=12.9.1 +ARG CUDA_VERSION=13.0.1 FROM nvidia/cuda:${CUDA_VERSION}-cudnn-devel-ubuntu24.04 AS base ARG TARGETARCH @@ -40,11 +40,11 @@ RUN if [ -n "$UBUNTU_MIRROR" ]; then \ fi # Python setup (combined with apt update to reduce layers) +# Ubuntu 24.04 ships Python 3.12 in main, so we no longer need the deadsnakes +# PPA. Dropping it avoids transient Launchpad 504s in `add-apt-repository`. RUN --mount=type=cache,target=/var/cache/apt,id=base-apt \ apt update && apt install -y --no-install-recommends wget software-properties-common \ - && add-apt-repository ppa:deadsnakes/ppa -y \ - && apt install -y --no-install-recommends python3.12-full python3.12-dev python3.10-venv \ - && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 \ + && apt install -y --no-install-recommends python3.12-full python3.12-dev \ && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2 \ && update-alternatives --set python3 /usr/bin/python3.12 \ && wget -q https://bootstrap.pypa.io/get-pip.py \ @@ -54,7 +54,7 @@ RUN --mount=type=cache,target=/var/cache/apt,id=base-apt \ && python3 -m pip config set global.break-system-packages true \ # Fix for apt-add-repository && cd /usr/lib/python3/dist-packages/ \ - && ln -s apt_pkg.cpython-310-*-linux-gnu.so apt_pkg.so + && ln -s apt_pkg.cpython-312-*-linux-gnu.so apt_pkg.so # Install system dependencies (organized by category for better caching) RUN --mount=type=cache,target=/var/cache/apt,id=base-apt \ @@ -202,10 +202,11 @@ RUN --mount=type=cache,target=/root/.cache/pip \ python3 -m pip install https://${GITHUB_ARTIFACTORY}/sgl-project/whl/releases/download/v${SGL_KERNEL_VERSION}/sglang_kernel-${SGL_KERNEL_VERSION}+cu124-cp310-abi3-manylinux2014_$(uname -m).whl --force-reinstall --no-deps \ ; \ elif [ "$CUDA_VERSION" = "12.8.1" ] || [ "$CUDA_VERSION" = "12.9.1" ]; then \ - python3 -m pip install sglang-kernel==${SGL_KERNEL_VERSION} \ + python3 -m pip install https://github.com/sgl-project/whl/releases/download/v${SGL_KERNEL_VERSION}/sglang_kernel-${SGL_KERNEL_VERSION}+cu129-cp310-abi3-manylinux2014_$(uname -m).whl --force-reinstall --no-deps \ ; \ elif [ "$CUDA_VERSION" = "13.0.1" ]; then \ - python3 -m pip install https://github.com/sgl-project/whl/releases/download/v${SGL_KERNEL_VERSION}/sglang_kernel-${SGL_KERNEL_VERSION}+cu130-cp310-abi3-manylinux2014_$(uname -m).whl --force-reinstall --no-deps \ + # --no-deps prevents pip from pulling torch from default PyPI + python3 -m pip install sglang-kernel==${SGL_KERNEL_VERSION} --force-reinstall --no-deps \ ; \ else \ echo "Unsupported CUDA version: $CUDA_VERSION" && exit 1 \ @@ -238,6 +239,12 @@ RUN --mount=type=cache,target=/root/.cache/pip \ && touch README.md \ && touch LICENSE \ && python3 -m pip install --extra-index-url https://download.pytorch.org/whl/cu${CUINDEX} ".[${BUILD_TYPE}]" \ + && if [ "${CUDA_VERSION%%.*}" = "12" ]; then \ + pip list --format=freeze | awk -F'==' '/-cu13(==|$)/ {print $1}' \ + | xargs -r python3 -m pip uninstall -y && \ + python3 -m pip install --index-url https://download.pytorch.org/whl/cu${CUINDEX} \ + torch torchvision torchaudio --force-reinstall; \ + fi \ && cd /sgl-workspace \ && rm -rf /tmp/sglang_deps \ && pip freeze | grep -v "^sglang==" > /sgl-workspace/constraints.txt @@ -519,7 +526,6 @@ RUN --mount=type=cache,target=/root/.cache/pip \ uv \ wheel \ scikit-build-core \ - nixl \ py-spy \ cubloaty \ google-cloud-storage \ @@ -529,19 +535,14 @@ RUN --mount=type=cache,target=/root/.cache/pip \ termplotlib \ "runai-model-streamer[s3,gcs,azure]>=0.15.7" -RUN --mount=type=cache,target=/root/.cache/pip \ - python3 -m pip install "nvidia-cutlass-dsl>=4.4.1" "nvidia-cutlass-dsl-libs-base>=4.4.1" --force-reinstall --no-deps; - -# Patching packages for CUDA 12/13 compatibility -# TODO: Remove when torch version covers these packages +# Per-CUDA-major package installs. The `nixl` stub package is needed (it owns +# the `nixl` import path) but unconditionally requires nixl-cu12, so we install +# it with --no-deps and pair it with the matching nixl-cu12 / nixl-cu13 binary +# to avoid shipping wrong-CUDA libs on cu13 images. RUN --mount=type=cache,target=/root/.cache/pip if [ "${CUDA_VERSION%%.*}" = "12" ]; then \ - python3 -m pip install nvidia-nccl-cu12==2.28.3 --force-reinstall --no-deps ; \ - python3 -m pip install nvidia-cudnn-cu12==9.16.0.29 --force-reinstall --no-deps ; \ + python3 -m pip install nixl-cu12 --no-deps ; \ python3 -m pip install cuda-python==12.9 ; \ elif [ "${CUDA_VERSION%%.*}" = "13" ]; then \ - python3 -m pip install nvidia-nccl-cu13==2.28.3 --force-reinstall --no-deps ; \ - python3 -m pip install nvidia-cudnn-cu13==9.16.0.29 --force-reinstall --no-deps ; \ - python3 -m pip install nvidia-cublas==13.1.0.3 --force-reinstall --no-deps ; \ python3 -m pip install nixl-cu13 --no-deps ; \ python3 -m pip install cuda-python==13.2.0 ; \ fi @@ -557,12 +558,6 @@ COPY docker/configs/opt/.gitconfig /opt/sglang/.gitconfig # Configure development environment COPY docker/configs/.zshrc /root/.zshrc -# Fix Triton to use system ptxas for Blackwell (sm_103a) support (CUDA 13+ only) -RUN if [ "${CUDA_VERSION%%.*}" = "13" ] && [ -d /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin ]; then \ - rm -f /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin/ptxas && \ - ln -s /usr/local/cuda/bin/ptxas /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin/ptxas; \ - fi - # Fix Trivy-reported CVEs # pip: urllib3 (CVE-2025-43859), pillow (CVE-2026-25990) # binutils family: CVE-2025-{1147,1148,3198,5244,5245,7545,7546,8225,11082,11083,11412,11413,11414,11494,11839,11840} @@ -687,12 +682,10 @@ ENV PATH="${PATH}:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/cuda/nvvm LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64" # Install runtime dependencies (devel base provides gcc/g++/build tools) +# Python 3.12 ships in Ubuntu 24.04 main, so no deadsnakes PPA needed. RUN --mount=type=cache,target=/var/cache/apt,id=runtime-apt \ - apt-get update && apt-get install -y --no-install-recommends \ + apt-get update && apt-get install -y --no-install-recommends --allow-change-held-packages \ # Python runtime - software-properties-common \ - && add-apt-repository ppa:deadsnakes/ppa -y \ - && apt-get update && apt-get install -y --no-install-recommends --allow-change-held-packages \ python3.12-full \ python3.12-dev \ wget \ @@ -781,12 +774,6 @@ COPY --from=framework_final /usr/local/bin/py-spy /usr/local/bin/py-spy COPY --from=framework_final /root/.cache/huggingface /root/.cache/huggingface COPY --from=framework_final /root/.cache/sglang /root/.cache/sglang -# Fix Triton to use system ptxas for Blackwell (sm_103a) support (CUDA 13+ only) -RUN if [ "${CUDA_VERSION%%.*}" = "13" ] && [ -d /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin ]; then \ - rm -f /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin/ptxas && \ - ln -s /usr/local/cuda/bin/ptxas /usr/local/lib/python3.12/dist-packages/triton/backends/nvidia/bin/ptxas; \ - fi - # Copy GDRCopy runtime libraries (but not the build artifacts) COPY --from=framework_final /usr/lib/libgdrapi.so* /usr/lib/ COPY --from=framework_final /usr/bin/gdrcopy_* /usr/bin/ diff --git a/docker/diffusion.Dockerfile b/docker/diffusion.Dockerfile deleted file mode 100644 index d8af45b7c..000000000 --- a/docker/diffusion.Dockerfile +++ /dev/null @@ -1,104 +0,0 @@ -FROM nvidia/cuda:12.8.0-cudnn-devel-ubuntu22.04 - -ENV DEBIAN_FRONTEND=noninteractive - -SHELL ["/bin/bash", "-c"] - -WORKDIR /sgl-workspace/sglang - -RUN apt-get update && apt-get install -y --no-install-recommends \ - wget \ - git \ - ca-certificates \ - openssh-server \ - zsh \ - vim \ - curl \ - gcc-11 \ - g++-11 \ - clang-11 \ - libnuma1 libnuma-dev \ - && rm -rf /var/lib/apt/lists/* - -# Install oh-my-zsh and plugins -RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended \ - && git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions \ - && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting - - -# Set up C++20 compilers for ThunderKittens -RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 - -# Set CUDA environment variables -ENV CUDA_HOME=/usr/local/cuda-12.8 -ENV PATH=${CUDA_HOME}/bin:${PATH} -ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH - -# Install uv and source its environment -RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \ - echo 'source $HOME/.local/bin/env' >> /root/.zshrc - -# Copy just the pyproject.toml first to leverage Docker cache -COPY python/pyproject.toml python/ - -# Create a dummy README to satisfy the installation -RUN mkdir -p python && echo "# Placeholder" > python/README.md - -# Create and activate virtual environment with specific Python version and seed -RUN source $HOME/.local/bin/env && \ - uv venv --python 3.12 --seed /opt/venv && \ - source /opt/venv/bin/activate && \ - uv pip install nvitop && \ - uv pip install --no-cache-dir --upgrade pip && \ - uv pip install --no-cache-dir --prerelease=allow ./python[diffusion] - -COPY . . - -# Install dependencies using uv and set up shell configuration -RUN source $HOME/.local/bin/env && \ - source /opt/venv/bin/activate && \ - git config --unset-all http.https://github.com/.extraheader || true && \ - echo 'source /opt/venv/bin/activate' >> /root/.zshrc && \ - echo 'if [ -n "$ZSH_VERSION" ] && [ -f ~/.zshrc ]; then . ~/.zshrc; elif [ -f ~/.bashrc ]; then . ~/.bashrc; fi' > /root/.profile - -# Set PATH to include venv bin -ENV PATH=/opt/venv/bin:$PATH - -# Configure zsh -COPY --chown=root:root <<-"EOF" /root/.zshrc -export ZSH="/root/.oh-my-zsh" - -source $HOME/.local/bin/env -source /opt/venv/bin/activate - -## Theme -ZSH_THEME="robbyrussell" - -## Plugins -plugins=( - git - z - zsh-autosuggestions - zsh-syntax-highlighting -) - -source $ZSH/oh-my-zsh.sh - -## Aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' -alias vi='vim' - -## Enhanced history -HISTSIZE=10000 -SAVEHIST=10000 -setopt HIST_IGNORE_ALL_DUPS -setopt HIST_FIND_NO_DUPS -setopt INC_APPEND_HISTORY -EOF - - -EXPOSE 22 - -CMD ["/bin/zsh"] diff --git a/scripts/ci/utils/docker_build_metadata_args.py b/scripts/ci/utils/docker_build_metadata_args.py index ea83d6449..79a41a656 100644 --- a/scripts/ci/utils/docker_build_metadata_args.py +++ b/scripts/ci/utils/docker_build_metadata_args.py @@ -3,7 +3,7 @@ import datetime import json import sys -MOVING_TAGS = {"dev", "dev-cu13", "latest"} +MOVING_TAGS = {"dev", "dev-cu12", "dev-cu13", "latest"} def render_tag_template(tag: str, version: str, date: str, short_sha: str) -> str: