From 57e01ee01223029736efd165fcc0e6583fd65e3d Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 19 Sep 2025 21:50:15 +0800 Subject: [PATCH] . --- Dockerfile | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 03bbd3e3f..bff572148 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY --from=builder-torch /opt/pytorch/dist /tmp/torch_dist RUN set -e && \ echo "==> Files in /tmp/torch_dist:" && ls -lh /tmp/torch_dist && \ - find /tmp/torch_dist -name 'torch-*.whl' -print | xargs -r python3 -m pip install --no-cache-dir + find /tmp/torch_dist -name 'torch-*.whl' -print | xargs -r python3 -m pip install --no-cache-dir --no-deps # ── 编译 torchvision 0.22.1 (依赖本地 torch) ──────────────────────────────── @@ -103,7 +103,6 @@ RUN bash -lc '\ /usr/local/cuda/bin/ptxas --version \ ' - # 限制构建并行;避免 ptxas 多线程崩溃 ENV CMAKE_BUILD_PARALLEL_LEVEL=8 ENV SGL_KERNEL_COMPILE_THREADS=1 @@ -123,12 +122,20 @@ RUN python3 -m pip install --no-cache-dir "cmake>=3.27,<4.0" scikit-build-core== ' -# ★ 生成 constraints,强制 sgl-kernel 只能用本地 wheel -RUN bash -lc 'set -e; \ - WHEEL=$(ls /tmp/sgl_kernel_wheels/sgl_kernel-*.whl | head -n1); \ - echo "sgl-kernel @ file://$WHEEL" > /tmp/sgl_constraints.txt; \ - echo ">>> Using constraint:"; cat /tmp/sgl_constraints.txt' - +# ★ 构建期 constraints:把自编的 torch / sgl-kernel / flashinfer 都锁到本地 wheel +RUN bash -lc '\ + set -euo pipefail; \ + TWHL=$(ls /tmp/torch_dist/torch-*.whl | head -n1); \ + SKWHL=$(ls /tmp/sgl_kernel_wheels/sgl_kernel-*.whl | head -n1); \ + FWHL=$(ls /opt/flashinfer/dist/flashinfer_python-*.whl 2>/dev/null | head -n1 || true); \ + : > /tmp/local_constraints_build.txt; \ + echo "torch @ file://$TWHL" >> /tmp/local_constraints_build.txt; \ + echo "sgl-kernel @ file://$SKWHL" >> /tmp/local_constraints_build.txt; \ + if [ -n "$FWHL" ]; then \ + echo "flashinfer-python @ file://$FWHL" >> /tmp/local_constraints_build.txt; \ + fi; \ + echo ">>> build-time constraints:"; cat /tmp/local_constraints_build.txt \ +' RUN python3 -m pip install --no-cache-dir --no-deps /tmp/sgl_kernel_wheels/sgl_kernel-*.whl @@ -137,15 +144,10 @@ RUN python3 -m pip install --no-cache-dir --no-deps /tmp/sgl_kernel_wheels/sgl_k WORKDIR /opt RUN pip download --only-binary=:all: --no-deps vllm==0.9.1 -d /tmp/vllm_wheels - # ── 编译你本地 sglang 源码并打 wheel ─────────────────────────────────────── -# COPY ./sglang /sgl/sglang -# WORKDIR /sgl/sglang/python -# RUN python3 -m pip install ".[srt,openai]" --no-build-isolation && \ -# python3 -m pip wheel ".[srt,openai]" --no-deps -w /tmp/sg_wheels WORKDIR /sgl/sglang/python -RUN python3 -m pip install --no-build-isolation -c /tmp/sgl_constraints.txt ".[srt,openai]" && \ - python3 -m pip wheel --no-build-isolation -c /tmp/sgl_constraints.txt ".[srt,openai]" -w /tmp/sg_wheels +RUN python3 -m pip install --no-build-isolation -c /tmp/local_constraints_build.txt ".[srt,openai]" && \ + python3 -m pip wheel --no-build-isolation -c /tmp/local_constraints_build.txt ".[srt,openai]" -w /tmp/sg_wheels # ── 收集所有 wheel 到 /wheels ──────────────────────────────────────────────