本地shadowsocks修改为国内镜像方案
This commit is contained in:
+21
-19
@@ -2,6 +2,7 @@
|
|||||||
# MinerU on ROCm 7.2.1 Docker Image
|
# 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
|
# 原生 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)
|
# 构建前请根据你的 GPU 修改 ARCH 参数(默认 gfx1201 = RX 9070)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
@@ -14,10 +15,11 @@ ARG PYTHON_VER=3.12
|
|||||||
ARG VENV=/opt/mineru_venv
|
ARG VENV=/opt/mineru_venv
|
||||||
ARG TORCH_INDEX=https://download.pytorch.org/whl/rocm7.2
|
ARG TORCH_INDEX=https://download.pytorch.org/whl/rocm7.2
|
||||||
|
|
||||||
# -- 代理设置(国内构建必需)------------------------------------------------
|
# -- 国内镜像配置 -----------------------------------------------------------
|
||||||
ARG HTTP_PROXY
|
# GitHub 加速(ghproxy.com)
|
||||||
ARG HTTPS_PROXY
|
ARG GH_PROXY=https://ghproxy.com/
|
||||||
ARG NO_PROXY=localhost,127.0.0.1
|
# PyPI 镜像
|
||||||
|
ARG PIP_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
# -- 环境变量 ---------------------------------------------------------------
|
# -- 环境变量 ---------------------------------------------------------------
|
||||||
ENV DEBIAN_FRONTEND=noninteractive \
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
@@ -27,13 +29,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
|||||||
MINERU_MODEL_SOURCE=huggingface \
|
MINERU_MODEL_SOURCE=huggingface \
|
||||||
TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 \
|
TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 \
|
||||||
HSA_ENABLE_SDMA=1 \
|
HSA_ENABLE_SDMA=1 \
|
||||||
VLLM_TARGET_DEVICE=rocm \
|
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}
|
|
||||||
|
|
||||||
WORKDIR /opt
|
WORKDIR /opt
|
||||||
|
|
||||||
@@ -43,12 +39,9 @@ WORKDIR /opt
|
|||||||
# Ubuntu 24.04 使用 deb822 格式,默认源文件是 /etc/apt/sources.list.d/ubuntu.sources
|
# 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 && \
|
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 && \
|
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 \
|
apt-get update && apt-get install -y --no-install-recommends \
|
||||||
wget curl ca-certificates gnupg software-properties-common && \
|
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 - | \
|
wget -q https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
|
||||||
gpg --dearmor | tee /etc/apt/trusted.gpg.d/rocm.gpg > /dev/null && \
|
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' \
|
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 不够)
|
# 阶段 4:CMake 4.0(vllm 要求 ≥ 4.0,Ubuntu 24.04 自带 3.28 不够)
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
RUN cd /tmp && \
|
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 && \
|
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/bin/* /usr/local/bin/ && \
|
||||||
cp -r cmake-4.0.0-linux-x86_64/share/* /usr/local/share/ && \
|
cp -r cmake-4.0.0-linux-x86_64/share/* /usr/local/share/ && \
|
||||||
@@ -112,8 +105,12 @@ RUN cd /tmp && \
|
|||||||
# 阶段 5:Python 虚拟环境 + PyTorch ROCm
|
# 阶段 5:Python 虚拟环境 + PyTorch ROCm
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
RUN python${PYTHON_VER} -m venv ${VENV} && \
|
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 && \
|
${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 \
|
${VENV}/bin/pip install --no-cache-dir --pre \
|
||||||
torch==2.11.0+rocm7.2 \
|
torch==2.11.0+rocm7.2 \
|
||||||
torchvision \
|
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/*
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
# 阶段 7:amd-aiter + flash_attn
|
# 阶段 7:amd-aiter + flash_attn(GitHub 通过 ghproxy 加速)
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
RUN set -ex && \
|
RUN set -ex && \
|
||||||
|
# 配置 git 走 ghproxy
|
||||||
|
git config --global url."${GH_PROXY}https://github.com/".insteadOf "https://github.com/" && \
|
||||||
# aiter(AMD 优化的 attention 算子)
|
# aiter(AMD 优化的 attention 算子)
|
||||||
cd /opt && git clone --recursive --depth 1 https://github.com/ROCm/aiter.git && \
|
cd /opt && git clone --recursive --depth 1 https://github.com/ROCm/aiter.git && \
|
||||||
${VENV}/bin/pip install --no-cache-dir -e /opt/aiter && \
|
${VENV}/bin/pip install --no-cache-dir -e /opt/aiter && \
|
||||||
@@ -149,6 +148,8 @@ RUN set -ex && \
|
|||||||
# 阶段 8:编译 vllm
|
# 阶段 8:编译 vllm
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
RUN set -ex && \
|
RUN set -ex && \
|
||||||
|
# 配置 git 走 ghproxy(新 RUN 层需重新配置)
|
||||||
|
git config --global url."${GH_PROXY}https://github.com/".insteadOf "https://github.com/" && \
|
||||||
# setuptools 升级(PEP 639 兼容)
|
# setuptools 升级(PEP 639 兼容)
|
||||||
${VENV}/bin/pip install --no-cache-dir -U \
|
${VENV}/bin/pip install --no-cache-dir -U \
|
||||||
"setuptools>=77.0.3" setuptools_scm setuptools_rust wheel && \
|
"setuptools>=77.0.3" setuptools_scm setuptools_rust wheel && \
|
||||||
@@ -172,7 +173,7 @@ RUN set -ex && \
|
|||||||
cd /opt/vllm_build && ninja -j8 && \
|
cd /opt/vllm_build && ninja -j8 && \
|
||||||
# 安装 .so 到 vllm 源码目录
|
# 安装 .so 到 vllm 源码目录
|
||||||
cp /opt/vllm_build/*.abi3.so /opt/vllm/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 && \
|
cd /opt/vllm && ${VENV}/bin/pip install --no-cache-dir -e . --no-build-isolation && \
|
||||||
# 验证 PyTorch 没被 vllm 依赖覆盖
|
# 验证 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)" && \
|
${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 适配补丁
|
# 阶段 9:安装 MinerU + RDNA 适配补丁
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
RUN set -ex && \
|
RUN set -ex && \
|
||||||
|
# pip 国内镜像已在阶段 5 全局配置
|
||||||
${VENV}/bin/pip install --no-cache-dir 'mineru[core]' && \
|
${VENV}/bin/pip install --no-cache-dir 'mineru[core]' && \
|
||||||
# 验证 PyTorch 没被覆盖
|
# 验证 PyTorch 没被覆盖
|
||||||
${VENV}/bin/python -c "import torch; v=torch.__version__; assert 'rocm' in v, f'PyTorch overwritten: {v}'; print('PyTorch OK:', v)" && \
|
${VENV}/bin/python -c "import torch; v=torch.__version__; assert 'rocm' in v, f'PyTorch overwritten: {v}'; print('PyTorch OK:', v)" && \
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
network: host # 构建时走宿主机网络(国内访问 ROCm 源需要)
|
|
||||||
args:
|
args:
|
||||||
# ---- 按你的 GPU 修改 ----
|
# ---- 按你的 GPU 修改 ----
|
||||||
# gfx1201 = RX 9070 / 9070 XT / 9070 GRE
|
# gfx1201 = RX 9070 / 9070 XT / 9070 GRE
|
||||||
@@ -18,9 +17,10 @@ services:
|
|||||||
# gfx1101 = RX 7800 XT / 7700 XT
|
# gfx1101 = RX 7800 XT / 7700 XT
|
||||||
# gfx1030 = RX 6950 / 6900 / 6800 系列
|
# gfx1030 = RX 6950 / 6900 / 6800 系列
|
||||||
ARCH: gfx1201
|
ARCH: gfx1201
|
||||||
# ---- 代理(国内必需)----
|
# ---- GitHub 加速代理(国内构建用,若 ghproxy 不可用请更换)----
|
||||||
HTTP_PROXY: http://127.0.0.1:8118
|
# GH_PROXY: https://ghproxy.com/
|
||||||
HTTPS_PROXY: http://127.0.0.1:8118
|
# ---- PyPI 镜像(国内构建用)----
|
||||||
|
# PIP_INDEX: https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
container_name: mineru-rocm
|
container_name: mineru-rocm
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
@@ -39,8 +39,6 @@ services:
|
|||||||
group_add:
|
group_add:
|
||||||
- video # /dev/dri/render* 权限
|
- video # /dev/dri/render* 权限
|
||||||
- render # /dev/kfd 权限
|
- render # /dev/kfd 权限
|
||||||
# 如果要与宿主机用户对齐,取消下面注释并改为你的 UID/GID
|
|
||||||
# user: "${UID:-1000}:${GID:-1000}"
|
|
||||||
|
|
||||||
# ---- 环境变量 ----
|
# ---- 环境变量 ----
|
||||||
environment:
|
environment:
|
||||||
@@ -59,12 +57,6 @@ services:
|
|||||||
- ${MIOPEN_CACHE:-./data/miopen}:/root/.cache/miopen
|
- ${MIOPEN_CACHE:-./data/miopen}:/root/.cache/miopen
|
||||||
|
|
||||||
# ---- 启动命令(默认 bash,可改)----
|
# ---- 启动命令(默认 bash,可改)----
|
||||||
# 例如直接处理 PDF:
|
|
||||||
# command: mineru -p /data/input/example.pdf -o /data/output -b hybrid-auto-engine
|
|
||||||
# 启动 WebUI:
|
|
||||||
# command: mineru-gradio --server-name 0.0.0.0 --server-port 7860
|
|
||||||
# 启动 API:
|
|
||||||
# command: mineru-api --host 0.0.0.0 --port 8000
|
|
||||||
command: bash
|
command: bash
|
||||||
|
|
||||||
# ---- 端口(WebUI / API 模式时启用)----
|
# ---- 端口(WebUI / API 模式时启用)----
|
||||||
|
|||||||
Reference in New Issue
Block a user