本地shadowsocks修改为国内镜像方案

This commit is contained in:
2026-06-03 16:33:45 +08:00
parent e95ccb6d05
commit 093da7722a
2 changed files with 25 additions and 31 deletions
+21 -19
View File
@@ -2,6 +2,7 @@
# MinerU on ROCm 7.2.1 Docker Image
# 原生 Linux + Ubuntu 24.04 + ROCm 7.2.1 + PyTorch 2.11.0 + vllm + MinerU 3.2.0
#
# 国内网络优化版:Ubuntu/PyPI/GitHub 全部使用国内镜像
# 构建前请根据你的 GPU 修改 ARCH 参数(默认 gfx1201 = RX 9070)
# =============================================================================
@@ -14,10 +15,11 @@ ARG PYTHON_VER=3.12
ARG VENV=/opt/mineru_venv
ARG TORCH_INDEX=https://download.pytorch.org/whl/rocm7.2
# -- 代理设置(国内构建必需)------------------------------------------------
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG NO_PROXY=localhost,127.0.0.1
# -- 国内镜像配置 -----------------------------------------------------------
# GitHub 加速(ghproxy.com)
ARG GH_PROXY=https://ghproxy.com/
# PyPI 镜像
ARG PIP_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
# -- 环境变量 ---------------------------------------------------------------
ENV DEBIAN_FRONTEND=noninteractive \
@@ -27,13 +29,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
MINERU_MODEL_SOURCE=huggingface \
TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 \
HSA_ENABLE_SDMA=1 \
VLLM_TARGET_DEVICE=rocm \
HTTP_PROXY=${HTTP_PROXY} \
HTTPS_PROXY=${HTTPS_PROXY} \
NO_PROXY=${NO_PROXY} \
http_proxy=${HTTP_PROXY} \
https_proxy=${HTTPS_PROXY} \
no_proxy=${NO_PROXY}
VLLM_TARGET_DEVICE=rocm
WORKDIR /opt
@@ -43,12 +39,9 @@ WORKDIR /opt
# Ubuntu 24.04 使用 deb822 格式,默认源文件是 /etc/apt/sources.list.d/ubuntu.sources
RUN sed -i 's|http://.*archive.ubuntu.com|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/ubuntu.sources && \
sed -i 's|http://.*security.ubuntu.com|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/ubuntu.sources && \
# 如果设置了代理,配置 apt 走代理
([ -n "$HTTP_PROXY" ] && echo "Acquire::http::Proxy \"$HTTP_PROXY\";" > /etc/apt/apt.conf.d/99proxy) || true && \
([ -n "$HTTPS_PROXY" ] && echo "Acquire::https::Proxy \"$HTTPS_PROXY\";" >> /etc/apt/apt.conf.d/99proxy) || true && \
apt-get update && apt-get install -y --no-install-recommends \
wget curl ca-certificates gnupg software-properties-common && \
# 添加 AMD ROCm 仓库
# 添加 AMD ROCm 仓库(repo.radeon.com 通常国内可直连)
wget -q https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
gpg --dearmor | tee /etc/apt/trusted.gpg.d/rocm.gpg > /dev/null && \
echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/7.2.1 noble main' \
@@ -101,7 +94,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# 阶段 4:CMake 4.0(vllm 要求 ≥ 4.0,Ubuntu 24.04 自带 3.28 不够)
# ===========================================================================
RUN cd /tmp && \
wget -q https://github.com/Kitware/CMake/releases/download/v4.0.0/cmake-4.0.0-linux-x86_64.tar.gz && \
wget -q ${GH_PROXY}https://github.com/Kitware/CMake/releases/download/v4.0.0/cmake-4.0.0-linux-x86_64.tar.gz && \
tar -xzf cmake-4.0.0-linux-x86_64.tar.gz && \
cp -r cmake-4.0.0-linux-x86_64/bin/* /usr/local/bin/ && \
cp -r cmake-4.0.0-linux-x86_64/share/* /usr/local/share/ && \
@@ -112,8 +105,12 @@ RUN cd /tmp && \
# 阶段 5:Python 虚拟环境 + PyTorch ROCm
# ===========================================================================
RUN python${PYTHON_VER} -m venv ${VENV} && \
# 配置 pip 国内镜像
mkdir -p /root/.pip && \
echo "[global]" > /root/.pip/pip.conf && \
echo "index-url = ${PIP_INDEX}" >> /root/.pip/pip.conf && \
${VENV}/bin/pip install --no-cache-dir -U pip setuptools wheel && \
# 安装 PyTorch ROCm 版(锁定 2.11,≥ 2.12 在部分环境下有 rocprofiler 问题)
# 安装 PyTorch ROCm 版(指定 index-url 覆盖全局镜像)
${VENV}/bin/pip install --no-cache-dir --pre \
torch==2.11.0+rocm7.2 \
torchvision \
@@ -132,9 +129,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
apt-get clean && rm -rf /var/lib/apt/lists/*
# ===========================================================================
# 阶段 7:amd-aiter + flash_attn
# 阶段 7:amd-aiter + flash_attn(GitHub 通过 ghproxy 加速)
# ===========================================================================
RUN set -ex && \
# 配置 git 走 ghproxy
git config --global url."${GH_PROXY}https://github.com/".insteadOf "https://github.com/" && \
# aiter(AMD 优化的 attention 算子)
cd /opt && git clone --recursive --depth 1 https://github.com/ROCm/aiter.git && \
${VENV}/bin/pip install --no-cache-dir -e /opt/aiter && \
@@ -149,6 +148,8 @@ RUN set -ex && \
# 阶段 8:编译 vllm
# ===========================================================================
RUN set -ex && \
# 配置 git 走 ghproxy(新 RUN 层需重新配置)
git config --global url."${GH_PROXY}https://github.com/".insteadOf "https://github.com/" && \
# setuptools 升级(PEP 639 兼容)
${VENV}/bin/pip install --no-cache-dir -U \
"setuptools>=77.0.3" setuptools_scm setuptools_rust wheel && \
@@ -172,7 +173,7 @@ RUN set -ex && \
cd /opt/vllm_build && ninja -j8 && \
# 安装 .so 到 vllm 源码目录
cp /opt/vllm_build/*.abi3.so /opt/vllm/vllm/ && \
# pip install vllm(让 pip 解析运行时依赖:xgrammar, compressed_tensors 等)
# pip install vllm(让 pip 解析运行时依赖)
cd /opt/vllm && ${VENV}/bin/pip install --no-cache-dir -e . --no-build-isolation && \
# 验证 PyTorch 没被 vllm 依赖覆盖
${VENV}/bin/python -c "import torch; v=torch.__version__; assert 'rocm' in v, f'PyTorch overwritten by vllm deps: {v}'; print('PyTorch OK:', v)" && \
@@ -196,6 +197,7 @@ COPY scripts/cache_warmer.py /opt/cache_warmer.py
# 阶段 9:安装 MinerU + RDNA 适配补丁
# ===========================================================================
RUN set -ex && \
# pip 国内镜像已在阶段 5 全局配置
${VENV}/bin/pip install --no-cache-dir 'mineru[core]' && \
# 验证 PyTorch 没被覆盖
${VENV}/bin/python -c "import torch; v=torch.__version__; assert 'rocm' in v, f'PyTorch overwritten: {v}'; print('PyTorch OK:', v)" && \