From 2aff032bc200a7a1b79ce1999a236bd5830c0d40 Mon Sep 17 00:00:00 2001 From: suluyan Date: Mon, 3 Aug 2026 16:17:55 +0800 Subject: [PATCH] fix(backport): drop ascend/npu diffs from release/1.39 sync Keep master's NPU Dockerfile and AscendImageBuilder untouched; PIP_EXTRA fallback remains only on non-ascend GPU image builders. Co-authored-by: Cursor --- docker/Dockerfile.ascend | 26 +++++++++++--------------- docker/build_image.py | 3 +-- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/docker/Dockerfile.ascend b/docker/Dockerfile.ascend index 6bf2e958..d15548b6 100644 --- a/docker/Dockerfile.ascend +++ b/docker/Dockerfile.ascend @@ -5,8 +5,6 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_RETRIES=10 \ SOC_VERSION={soc_version} \ CANN_VERSION={cann_version} -# Build-time only (ARG does not persist into the image). -ARG PIP_EXTRA_INDEX_URL=https://pypi.org/simple SHELL ["/bin/bash", "-c"] @@ -38,7 +36,12 @@ RUN set -eux; \ esac RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple && \ - pip config set install.trusted-host mirrors.aliyun.com + pip config set global.extra-index-url "https://pypi.org/simple" && \ + pip config set install.trusted-host mirrors.aliyun.com && \ + ARCH=$(uname -m) && \ + if [ "$ARCH" = "x86_64" ]; then \ + pip config set global.extra-index-url "https://pypi.org/simple https://download.pytorch.org/whl/cpu/"; \ + fi {extra_content} # ---------- Install vllm + vllm-ascend ---------- @@ -48,7 +51,6 @@ RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ git clone --depth 1 --branch {vllm_ascend_git_ref} https://github.com/vllm-project/vllm-ascend.git RUN ARCH=$(uname -m) && \ - export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ source /usr/local/Ascend/nnal/atb/set_env.sh && \ # Install torch & torch_npu & torchvision @@ -64,8 +66,7 @@ RUN git clone --depth 1 --branch {megatron_branch} https://github.com/NVIDIA/Meg GIT_LFS_SKIP_SMUDGE=1 git clone --depth 1 -b {swift_branch} --single-branch https://github.com/modelscope/ms-swift.git /ms-swift # ---------- Install training-side repositories ---------- -RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ - source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ +RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ if [ -f /usr/local/Ascend/nnal/atb/set_env.sh ]; then source /usr/local/Ascend/nnal/atb/set_env.sh; fi && \ cd /MindSpeed && pip install --no-cache-dir -e . && \ pip install --no-cache-dir mcore-bridge -i https://pypi.org/simple/ -U && \ @@ -74,8 +75,7 @@ RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ # ---------- Pin torch to the correct version + torch_npu ---------- # x86: must force-install the CPU build from pytorch.org/whl/cpu # aarch64: PyPI only provides the CPU build, so install it directly from the Aliyun mirror -RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ - source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ +RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ if [ -f /usr/local/Ascend/nnal/atb/set_env.sh ]; then source /usr/local/Ascend/nnal/atb/set_env.sh; fi && \ ARCH=$(uname -m) && \ if [ "$ARCH" = "x86_64" ]; then \ @@ -99,8 +99,7 @@ ENV PYTHONPATH=/Megatron-LM:${PYTHONPATH} # install dependencies COPY requirements /var/modelscope -RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ - pip uninstall ms-swift modelscope -y && pip install --no-cache-dir pip==23.* -U && \ +RUN pip uninstall ms-swift modelscope -y && pip install --no-cache-dir pip==23.* -U && \ if [ "$INSTALL_MS_DEPS" = "True" ]; then \ pip install --no-cache-dir omegaconf==2.0.6 && \ pip install 'editdistance==0.8.1' && \ @@ -126,11 +125,9 @@ fi ARG CUR_TIME={cur_time} RUN echo $CUR_TIME -RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ - pip install --no-cache-dir --no-build-isolation OpenCC +RUN pip install --no-cache-dir --no-build-isolation OpenCC -RUN export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}" && \ - source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ +RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ if [ -f /usr/local/Ascend/nnal/atb/set_env.sh ]; then source /usr/local/Ascend/nnal/atb/set_env.sh; fi && \ pip install --no-cache-dir -U funasr scikit-learn && \ pip install --no-cache-dir -U qwen_vl_utils qwen_omni_utils librosa 'timm>=0.9.0' transformers accelerate peft trl safetensors && \ @@ -153,7 +150,6 @@ RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ # ---------- Install triton-ascend ---------- RUN set -eux; \ - export PIP_EXTRA_INDEX_URL="${PIP_EXTRA_INDEX_URL}"; \ pip uninstall -y triton || true; \ pip uninstall -y triton-ascend || true; \ pip install --no-cache-dir --force-reinstall \ diff --git a/docker/build_image.py b/docker/build_image.py index f5df8262..d7238868 100644 --- a/docker/build_image.py +++ b/docker/build_image.py @@ -1017,8 +1017,7 @@ class AscendImageBuilder(StableGPUImageBuilder): def generate_dockerfile(self) -> str: extra_content = """ -RUN export PIP_EXTRA_INDEX_URL=https://pypi.org/simple && \ - pip install --no-cache-dir -U icecream soundfile pybind11 py-spy +RUN pip install --no-cache-dir -U icecream soundfile pybind11 py-spy """ with open('docker/Dockerfile.ascend', 'r') as f: content = f.read()