执行摘要
- 一句话:更新 Ascend NPU Docker 至 CANN 9.0.0
- 推荐动作:建议仔细阅读 review 中的建议,并在后续 PR 中修复遗留问题。PR 本身完成了版本升级的目标,但实施细节有瑕疵。对于使用 Ascend NPU 的开发者,应关注修复后的 Dockerfile 版本。
功能与动机
升级 CANN 基础版本至 9.0.0,以支持最新的 Ascend 硬件和软件特性,保持 NPU 环境的兼容性。
实现拆解
- 新增 Dockerfile:在 docker/ascend/ 下新增 Dockerfile.ascend_9.0.0_a2 和 Dockerfile.ascend_9.0.0_a3,基于 CANN 9.0.0 镜像,安装 vLLM 0.18.0、vLLM-ascend、MindSpeed、Megatron-LM 等依赖。
- 更新 CI 工作流:修改 .github/workflows/docker-build-ascend-a2.yml 和 a3.yml,将引用的 Dockerfile 路径和镜像标签从 8.5.0 改为 9.0.0。
- 更新文档:在 docs/ascend_tutorial/get_start/dockerfile_build_guidance.rst 中添加 CANN 9.0.0 的镜像表格,并修正版本号。
- 修改依赖文件:从 requirements-npu.txt 中移除 triton-ascend==3.2.0(review 建议应更新至 3.2.1)。
关键文件:
docker/ascend/Dockerfile.ascend_9.0.0_a2(模块 Docker镜像;类别 infra;类型 infrastructure): 核心新增文件,定义 CANN 9.0.0 环境
docker/ascend/Dockerfile.ascend_9.0.0_a3(模块 Docker镜像;类别 infra;类型 infrastructure): 类似 A2 但针对 A3 设备
.github/workflows/docker-build-ascend-a2.yml(模块 CI配置;类别 infra;类型 infrastructure): CI 工作流引用新 Dockerfile
.github/workflows/docker-build-ascend-a3.yml(模块 CI配置;类别 infra;类型 infrastructure): 类似 A2 的 CI 变更
docs/ascend_tutorial/get_start/dockerfile_build_guidance.rst(模块 文档说明;类别 docs;类型 documentation): 更新文档以反映新版本
requirements-npu.txt(模块 依赖配置;类别 docs;类型 documentation): 移除了 triton-ascend 依赖
关键符号:未识别
关键源码片段
docker/ascend/Dockerfile.ascend_9.0.0_a2
核心新增文件,定义 CANN 9.0.0 环境
# 基于 CANN 9.0.0 基础镜像
FROM swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:9.0.0-910b-ubuntu22.04-py3.11
ARG SOC_VERSION="ascend910b1"
# 安装系统依赖
RUN apt-get update -y && \
apt-get install -y --no-install-recommends gcc g++ cmake libnuma-dev wget git curl jq vim build-essential && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
pip install --upgrade pip packaging setuptools==80.10.2 && \
pip cache purge
# 克隆第三方库
RUN ARCH=$(uname -m) && \
echo "[LOG INFO] Detected architecture: $ARCH" && \
if [ "$ARCH" = "x86_64" ]; then \
pip config set global.extra-index-url "https://download.pytorch.org/whl/cpu/"; \
fi && \
git clone --depth 1 --branch v0.18.0 https://github.com/vllm-project/vllm.git && \
git clone -b releases/v0.18.0 https://github.com/vllm-project/vllm-ascend.git && \
git clone https://gitcode.com/Ascend/MindSpeed.git && \
cd MindSpeed && git checkout 2.3.0_core_r0.12.1 && cd .. && \
git clone --depth 1 --branch core_v0.12.1 https://github.com/NVIDIA/Megatron-LM.git
# 安装第三方库(注意:此处使用 export 而非 ENV,环境变量不会持久化到后续 RUN)
RUN export PIP_EXTRA_INDEX_URL=https://triton-ascend.osinfra.cn/pypi/simple/ && \
export PIP_TRUSTED_HOST=triton-ascend.osinfra.cn && \
ARCH=$(uname -m) && \
if [ "$ARCH" = "aarch64" ]; then \
export LD_LIBRARY_PATH=/usr/local/Ascend/cann-9.0.0/aarch64-linux/devlib/linux/aarch64:$LD_LIBRARY_PATH; \
elif [ "$ARCH" = "x86_64" ]; then \
export LD_LIBRARY_PATH=/usr/local/Ascend/cann-9.0.0/x86_64-linux/devlib/linux/x86_64/:$LD_LIBRARY_PATH; \
fi && \
# source 命令在 dash shell 中不可用,应使用 . 代替
source /usr/local/Ascend/ascend-toolkit/set_env.sh && \
source /usr/local/Ascend/nnal/atb/set_env.sh && \
cd vllm && pip install -r requirements/build.txt && \
VLLM_TARGET_DEVICE=empty pip install -v -e. && cd .. && \
cd vllm-ascend && pip install -r requirements.txt && \
export COMPILE_CUSTOM_KERNELS=1 && pip install -v -e . && cd .. && \
pip install -e MindSpeed && \
pip install -e Megatron-LM && \
pip uninstall -y triton && \
pip install mbridge && \
rm -rf /tmp/* /var/tmp/* && \
pip cache purge
# 为 DeepSeek 模型修改 mbridge:将 cuda 替换为 npu(使用硬编码行号,脆弱)
RUN MBRIDGE_PATH=$(pip show mbridge | grep Location | awk '{print $2}') && \
TARGET_FILE="${MBRIDGE_PATH}/mbridge/models/ext/deepseek_v3/dequant_fp8_safetensor_io.py" && \
sed -i '34s/cuda/npu/;51s/cuda/npu/' "$TARGET_FILE"
# 克隆并安装 verl(使用 git clone 而非 COPY,无法包含本地变更)
RUN git clone --recursive https://github.com/verl-project/verl.git && \
cd verl && pip install -r requirements-npu.txt && pip install -v -e . && cd .. && \
rm -rf /tmp/* /var/tmp/* && \
pip cache purge
评论区精华
Review 由 gemini-code-assist[bot] 提出多个高优先级问题:
风险与影响
关联脉络
- PR #6816 [ci] fix: fix Megatron-Bridge version in e2e_ppo_trainer_megatron_sglang_ascend.yml and update megatron for sglang ascend: 同样涉及 Ascend Dockerfile 和 CI 配置修改,属于 NPU 基础设施持续改进的一部分。
- PR #6711 [ci] chore: solve dapo error and add three baselines for npu nightly ci: 也修改了 NPU CI 工作流和依赖,与本 PR 的 NPU Docker 升级同属 Ascend 环境维护线。
参与讨论