This commit is contained in:
parent
f15cdf981b
commit
36dbb5b691
52
Dockerfile
52
Dockerfile
|
|
@ -84,7 +84,7 @@ RUN python3 -m pip install ".[srt,openai]" --no-build-isolation && \
|
|||
|
||||
|
||||
# ── 🔄 下载 sgl-kernel(与 sglang 同步)───────────────────────────────────────
|
||||
RUN pip download --only-binary=:all: --no-deps sgl-kernel==0.3.7 -d /tmp/sgl_kernel_wheels
|
||||
RUN pip download --only-binary=:all: --no-deps sgl-kernel==0.3.9.post2 -d /tmp/sgl_kernel_wheels
|
||||
|
||||
# ── 收集所有 wheel 到 /wheels ──────────────────────────────────────────────
|
||||
RUN mkdir -p /wheels && \
|
||||
|
|
@ -109,11 +109,55 @@ RUN pip wheel "gradio==5.38.2" requests -w /wheels
|
|||
# 把运行时所需依赖也打包进入wheel ────────────────────────────────────────────────
|
||||
RUN pip wheel pybase64==1.3.2 -w /wheels
|
||||
|
||||
|
||||
# >>> ADD: 导出轮子的独立阶段
|
||||
FROM scratch AS wheelhouse
|
||||
COPY --from=builder-extras /wheels /
|
||||
# <<< END ADD
|
||||
|
||||
|
||||
# >>> ADD: 从宿主机目录 _wheelhouse/ 安装轮子的 runtime
|
||||
ARG CUDA_VERSION=12.6.1
|
||||
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu22.04 AS runtime-prebuilt
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive PYTHONUNBUFFERED=1 LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc g++ build-essential ninja-build cuda-compiler-12-6 \
|
||||
python3 python3-dev python3-pip python3-distutils curl ca-certificates \
|
||||
libopenblas-dev libgomp1 libcupti-dev libnuma1 libopenmpi-dev openmpi-bin libnuma-dev libpng16-16 libjpeg8 \
|
||||
libnccl2=2.22.3-1+cuda12.6 && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
python3 -m pip install --no-cache-dir --upgrade pip && \
|
||||
python3 -m pip install --no-cache-dir xgrammar
|
||||
|
||||
# 拷贝 cupti 动态库(与 autobuild 相同)
|
||||
COPY --from=builder-extras /usr/local/cuda/lib64/libcupti.so.12 /usr/lib/x86_64-linux-gnu/
|
||||
COPY --from=builder-extras /usr/local/cuda/lib64/libcupti.so /usr/lib/x86_64-linux-gnu/
|
||||
RUN ldconfig
|
||||
|
||||
# ★ 从宿主机构建上下文复制本地轮子(目录名固定:_wheelhouse/)
|
||||
COPY _wheelhouse/ /tmp/wheels/
|
||||
|
||||
# 安装顺序与 runtime-autobuild 完全一致(优先 torch,再装其它)
|
||||
RUN ls -lh /tmp/wheels || true && \
|
||||
rm -f /tmp/wheels/torch-2.7.1a0+*.whl && \
|
||||
rm -f /tmp/wheels/huggingface_hub-0.34.4*.whl || true && \
|
||||
python3 -m pip install --no-cache-dir --no-deps /tmp/wheels/torch*.whl && \
|
||||
python3 -m pip install --no-cache-dir --no-deps /tmp/wheels/vllm-*.whl || true && \
|
||||
python3 -m pip install --no-cache-dir --no-deps /tmp/wheels/sgl_kernel-*.whl || true && \
|
||||
python3 -m pip install --no-cache-dir --no-deps /tmp/wheels/gradio-5.38.2*.whl || true && \
|
||||
python3 -m pip install --no-cache-dir --no-deps $(find /tmp/wheels -maxdepth 1 -type f -name '*.whl' ! -name 'gradio-*' -printf "/tmp/wheels/%f ") && \
|
||||
python3 -c "import gradio, sys; print('✅ Gradio version =', gradio.__version__)" && \
|
||||
rm -rf /tmp/wheels
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Stage 2 ─ runtime:极简运行镜像,仅离线安装 wheel
|
||||
###############################################################################
|
||||
ARG CUDA_VERSION=12.6.1
|
||||
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu22.04
|
||||
FROM nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu22.04 AS runtime-autobuild
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive PYTHONUNBUFFERED=1 LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||
|
||||
|
|
@ -142,7 +186,7 @@ RUN ls -lh /tmp/wheels && \
|
|||
python3 -m pip install --no-cache-dir --no-deps /tmp/wheels/vllm-*.whl && \
|
||||
python3 -m pip install --no-cache-dir --no-deps /tmp/wheels/sgl_kernel-*.whl && \
|
||||
python3 -m pip install --no-cache-dir --no-deps /tmp/wheels/gradio-5.38.2*.whl && \
|
||||
python3 -m pip install --no-cache-dir --no-deps $(ls /tmp/wheels | grep -v '^gradio-' | sed 's|^|/tmp/wheels/|') && \
|
||||
# python3 -m pip install --no-cache-dir --no-deps $(ls /tmp/wheels | grep -v '^gradio-' | sed 's|^|/tmp/wheels/|') && \
|
||||
python3 -m pip install --no-cache-dir --no-deps $(find /tmp/wheels -maxdepth 1 -type f -name '*.whl' ! -name 'gradio-*') && \
|
||||
python3 -c "import gradio, sys; print('✅ Gradio version =', gradio.__version__)" && \
|
||||
rm -rf /tmp/wheels
|
||||
|
|
@ -185,3 +229,5 @@ COPY ./supervisord.conf /etc/supervisor/supervisord.conf
|
|||
|
||||
# 作为容器主进程运行 supervisor
|
||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue