diff --git a/docker/Dockerfile b/docker/Dockerfile index 6ec1af6..f0fca07 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,12 +8,17 @@ FROM ubuntu:24.04 # -- 构建参数 --------------------------------------------------------------- -# 改成你的 gfx 代号:gfx1201(RX 9070) gfx1200(RX 9060) gfx1100(RX 7900) gfx1101(RX 7800/7700) gfx1030(RX 6900/6800) +# GPU 架构:gfx1201(RX 9070) gfx1200(RX 9060) gfx1100(RX 7900) gfx1101(RX 7800/7700) gfx1030(RX 6900/6800) ARG ARCH=gfx1201 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 + # -- 环境变量 --------------------------------------------------------------- ENV DEBIAN_FRONTEND=noninteractive \ PATH=/opt/rocm/bin:/opt/rocm/llvm/bin:${VENV}/bin:${PATH} \ @@ -22,14 +27,26 @@ ENV DEBIAN_FRONTEND=noninteractive \ MINERU_MODEL_SOURCE=huggingface \ TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=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 # =========================================================================== -# 阶段 1:安装 ROCm 7.2.1 +# 阶段 1:换国内源 + 安装 ROCm 7.2.1 # =========================================================================== -RUN apt-get update && apt-get install -y --no-install-recommends \ +# 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 仓库 wget -q https://repo.radeon.com/rocm/rocm.gpg.key -O - | \ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 766e6ef..716bf41 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -9,6 +9,7 @@ services: build: context: . dockerfile: Dockerfile + network: host # 构建时走宿主机网络(国内访问 ROCm 源需要) args: # ---- 按你的 GPU 修改 ---- # gfx1201 = RX 9070 / 9070 XT / 9070 GRE @@ -17,6 +18,9 @@ services: # gfx1101 = RX 7800 XT / 7700 XT # gfx1030 = RX 6950 / 6900 / 6800 系列 ARCH: gfx1201 + # ---- 代理(国内必需)---- + HTTP_PROXY: http://127.0.0.1:8118 + HTTPS_PROXY: http://127.0.0.1:8118 container_name: mineru-rocm stdin_open: true tty: true