This commit is contained in:
hailin 2025-09-19 21:50:15 +08:00
parent bc8452f783
commit 57e01ee012
1 changed files with 17 additions and 15 deletions

View File

@ -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 COPY --from=builder-torch /opt/pytorch/dist /tmp/torch_dist
RUN set -e && \ RUN set -e && \
echo "==> Files in /tmp/torch_dist:" && ls -lh /tmp/torch_dist && \ 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) ──────────────────────────────── # ── 编译 torchvision 0.22.1 (依赖本地 torch) ────────────────────────────────
@ -103,7 +103,6 @@ RUN bash -lc '\
/usr/local/cuda/bin/ptxas --version \ /usr/local/cuda/bin/ptxas --version \
' '
# 限制构建并行;避免 ptxas 多线程崩溃 # 限制构建并行;避免 ptxas 多线程崩溃
ENV CMAKE_BUILD_PARALLEL_LEVEL=8 ENV CMAKE_BUILD_PARALLEL_LEVEL=8
ENV SGL_KERNEL_COMPILE_THREADS=1 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 # ★ 构建期 constraints把自编的 torch / sgl-kernel / flashinfer 都锁到本地 wheel
RUN bash -lc 'set -e; \ RUN bash -lc '\
WHEEL=$(ls /tmp/sgl_kernel_wheels/sgl_kernel-*.whl | head -n1); \ set -euo pipefail; \
echo "sgl-kernel @ file://$WHEEL" > /tmp/sgl_constraints.txt; \ TWHL=$(ls /tmp/torch_dist/torch-*.whl | head -n1); \
echo ">>> Using constraint:"; cat /tmp/sgl_constraints.txt' 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 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 WORKDIR /opt
RUN pip download --only-binary=:all: --no-deps vllm==0.9.1 -d /tmp/vllm_wheels RUN pip download --only-binary=:all: --no-deps vllm==0.9.1 -d /tmp/vllm_wheels
# ── 编译你本地 sglang 源码并打 wheel ─────────────────────────────────────── # ── 编译你本地 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 WORKDIR /sgl/sglang/python
RUN python3 -m pip install --no-build-isolation -c /tmp/sgl_constraints.txt ".[srt,openai]" && \ 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/sgl_constraints.txt ".[srt,openai]" -w /tmp/sg_wheels python3 -m pip wheel --no-build-isolation -c /tmp/local_constraints_build.txt ".[srt,openai]" -w /tmp/sg_wheels
# ── 收集所有 wheel 到 /wheels ────────────────────────────────────────────── # ── 收集所有 wheel 到 /wheels ──────────────────────────────────────────────