已合并
feat: add ci image build script and optimize image build process #4858
feat: add ci image build script and optimize image build process #4858
已合并
wxy1105创建于 7月25日
5 个文件变更+126-47
@@ -0,0 +1,73 @@
1+#!/bin/bash
2+# ============================================
3+# MindSpeed LLM CI 环境构建脚本
4+# ============================================
5+# 使用场景:CI 流水线中自动构建 Docker 镜像用于 UT/ST 测试
G
Gguihaowen6667月27日

注释建议用英文

likedislike
wxy1105
wxy1105
7月27日 评论:
6+# 用法:bash build_ci_envs.sh
7+ 
8+set -e
9+ 
10+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11+BUILD_SCRIPT="${SCRIPT_DIR}/../docker/image_build.sh"
12+ 
13+# 校验构建脚本是否存在
14+if [ ! -f "$BUILD_SCRIPT" ]; then
15+ echo "[ERROR] Build script not found: ${BUILD_SCRIPT}"
16+ exit 1
17+fi
18+ 
19+# ============================================================
20+# 默认 CI 参数(可根据实际 CI 环境调整)
21+# ============================================================
22+BASE_IMAGE="swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-openeuler24.03-py3.11"
23+TORCH_VERSION="2.7.1"
24+TORCH_NPU_VERSION="2.7.1.post6"
25+TRITON_ASCEND_VERSION="3.2.0"
26+MINDSPEED_BRANCH="master"
27+MEGATRON_BRANCH="core_v0.12.1"
28+MINDSPEED_LLM_VERSION="master"
29+ 
30+echo "=========================================="
31+echo "CI Environment Build Configuration"
32+echo "=========================================="
33+echo "Base Image: ${BASE_IMAGE}"
34+echo "Torch Version: ${TORCH_VERSION}"
35+echo "Torch-NPU Version: ${TORCH_NPU_VERSION}"
36+echo "Triton-Ascend Version: ${TRITON_ASCEND_VERSION}"
37+echo "MindSpeed-LLM Ver: ${MINDSPEED_LLM_VERSION}"
38+echo "MindSpeed Branch: ${MINDSPEED_BRANCH}"
39+echo "Megatron Branch: ${MEGATRON_BRANCH}"
40+echo "=========================================="
41+ 
42+# 切换到 docker 目录执行构建
43+cd "$SCRIPT_DIR/../docker"
44+ 
45+# 构建参数数组
46+BUILD_ARGS=(
47+ --base-image "$BASE_IMAGE"
48+ --torch-version "$TORCH_VERSION"
49+ --torch-npu-version "$TORCH_NPU_VERSION"
50+ --triton-ascend-version "$TRITON_ASCEND_VERSION"
51+ --mindspeed-llm-branch "$MINDSPEED_LLM_VERSION"
52+ --mindspeed-branch "$MINDSPEED_BRANCH"
53+ --megatron-branch "$MEGATRON_BRANCH"
54+ --cleanup-on-fail
55+)
56+ 
57+echo ""
58+echo "[CI] Starting image build..."
59+echo ""
60+ 
61+set +e
62+bash "$BUILD_SCRIPT" "${BUILD_ARGS[@]}"
63+BUILD_RESULT=$?
64+set -e
65+ 
66+if [ $BUILD_RESULT -eq 0 ]; then
67+ echo ""
68+ echo "[CI] Build completed successfully."
69+else
70+ echo ""
71+ echo "[CI] Build failed with exit code: ${BUILD_RESULT}"
72+ exit $BUILD_RESULT
atomgit-bot
atomgit-botatomgit-bot7月25日

🟡 Medium Priority

ci/build_ci_envs.sh 第 8 行设置了 set -e,第 61 行执行 bash "$BUILD_SCRIPT" "${BUILD_ARGS[@]}"。当构建失败时(image_build.sh 返回非零退出码),set -e 会立即终止当前脚本,导致第 63 行的 BUILD_RESULT=$? 以及第 65-71 行的错误处理分支永远不会被执行。CI 失败时将没有任何 "[CI] Build failed with exit code: ..." 的错误日志输出,只能看到 bash 的默认退出行为,增加排查难度。

建议:在调用构建脚本前临时关闭 set -e,或在调用时使用 || 捕获失败。推荐方案:在第 61 行前加 set +e,在第 63 行后加 set -e,与 image_build.sh 中的处理方式保持一致。

likedislike
73+fi
@@ -54,11 +54,6 @@ RUN chmod +x /tmp/configure_repo.sh && \
54 bash /tmp/configure_repo.sh && \54 bash /tmp/configure_repo.sh && \
55 rm /tmp/configure_repo.sh55 rm /tmp/configure_repo.sh
56 56 
57-# Clean YUM cache and temporary files
58-RUN yum clean all && \
59- rm -rf /var/cache/yum && \
60- rm -rf /tmp/* /var/tmp/* /var/log/*
61- 
62# Install system dependencies57# Install system dependencies
63RUN echo "Installing system dependencies..." && \58RUN echo "Installing system dependencies..." && \
64 if [ "$OS_FAMILY" = "openeuler" ]; then \59 if [ "$OS_FAMILY" = "openeuler" ]; then \
@@ -95,34 +90,14 @@ FROM base AS builder
95 90 
96ARG TORCH_VERSION=2.7.191ARG TORCH_VERSION=2.7.1
97ARG TORCH_NPU_VERSION=2.7.192ARG TORCH_NPU_VERSION=2.7.1
93+ARG TRITON_ASCEND_VERSION=3.2.1
98 94 
99WORKDIR /tmp95WORKDIR /tmp
100 96 
101-# Install Miniconda (auto-detect architecture)
102-RUN echo "=== Detecting system architecture ===" && \
103- arch=$(uname -m) && \
104- echo "Current architecture: $arch" && \
105- if [ "$arch" = "x86_64" ]; then \
106- MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-py311_26.1.1-1-Linux-x86_64.sh"; \
107- elif [ "$arch" = "aarch64" ]; then \
108- MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-py311_26.1.1-1-Linux-aarch64.sh"; \
109- fi && \
110- echo "Download URL: $MINICONDA_URL" && \
111- wget --no-check-certificate "$MINICONDA_URL" -O miniconda.sh && \
112- bash miniconda.sh -b -p /opt/conda && \
113- rm -f miniconda.sh && \
114- /opt/conda/bin/conda clean -ya && \
115- ln -sf /opt/conda/bin/python /usr/bin/python && \
116- ln -sf /opt/conda/bin/pip /usr/bin/pip
117- 
118-# Set environment variables for Conda
119-ENV PATH=/opt/conda/bin:$PATH
120-ENV CONDA_AUTO_UPDATE_CONDA=false
121- 
122# Configure pip source97# Configure pip source
123RUN pip config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple && \98RUN pip config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple && \
124- pip config set global.trusted-host "repo.huaweicloud.com" && \99+ pip config set global.extra-index-url "https://mirrors.aliyun.com/pypi/simple/ https://pypi.douban.com/simple/ https://pypi.tuna.tsinghua.edu.cn/simple/" && \
125- /opt/conda/bin/conda init bash100+ pip config set global.trusted-host "repo.huaweicloud.com mirrors.aliyun.com pypi.douban.com pypi.tuna.tsinghua.edu.cn"
126 101 
127# Install PyTorch and torch_npu (ONLINE INSTALL ONLY)102# Install PyTorch and torch_npu (ONLINE INSTALL ONLY)
128RUN echo "Installing PyTorch and torch_npu from PyPI..." && \103RUN echo "Installing PyTorch and torch_npu from PyPI..." && \
@@ -147,7 +122,12 @@ RUN echo "Installing PyTorch and torch_npu from PyPI..." && \
147 pip install --no-cache-dir torch-npu==${TORCH_NPU_VERSION} && break; \122 pip install --no-cache-dir torch-npu==${TORCH_NPU_VERSION} && break; \
148 done;123 done;
149 124 
150-RUN conda clean -ya125+# Install Triton-Ascend
126+RUN echo "Installing Triton-Ascend..." && \
127+ pip install --no-cache-dir triton-ascend==${TRITON_ASCEND_VERSION} --extra-index-url=https://triton-ascend.osinfra.cn/pypi/simple
128+ 
129+# Clean pip cache
130+RUN pip cache purge
151 131 
152# ------------------------------132# ------------------------------
153# Stage 3: Final Runtime Image133# Stage 3: Final Runtime Image
@@ -168,8 +148,14 @@ RUN git config --global http.sslVerify false
168RUN git clone https://gitcode.com/ascend/MindSpeed.git && \148RUN git clone https://gitcode.com/ascend/MindSpeed.git && \
169 cd MindSpeed && \149 cd MindSpeed && \
170 git checkout ${MINDSPEED_BRANCH} && \150 git checkout ${MINDSPEED_BRANCH} && \
171- pip3 install -r requirements.txt && \151+ pip3 install --no-cache-dir -r requirements.txt && \
172- pip3 install -e .152+ pip3 install --no-cache-dir -e .
153+ 
154+# Install FSDPTurbo
155+RUN git clone https://gitcode.com/Ascend/FSDPTurbo.git && \
156+ cd FSDPTurbo && \
157+ pip3 install --no-cache-dir -e . && \
158+ cd ..
atomgit-bot
atomgit-botatomgit-bot7月25日

🟡 Medium Priority

docker/Dockerfile 第 155-158 行新增了 FSDPTurbo 的安装步骤,使用 git clone 后直接安装,没有 git checkout 到特定分支或 tag。相比之下,同文件中的 MindSpeed、MindSpeed-LLM、Megatron-LM 均通过 ARG + git checkout 固定版本。FSDPTurbo 的默认分支内容可能随时变化,导致不同时间构建的镜像包含不同代码,破坏可复现性和 CI 一致性。

建议:添加 ARG 控制 FSDPTurbo 版本,并在 clone 后执行 git checkout。例如:增加 ARG FSDPTURBO_BRANCH=master,然后在 clone 后添加 git checkout ${FSDPTURBO_BRANCH} &&

likedislike
173 159 
174# Install MindSpeed-LLM and Megatron-LM160# Install MindSpeed-LLM and Megatron-LM
175RUN git clone https://gitcode.com/ascend/MindSpeed-LLM.git && \161RUN git clone https://gitcode.com/ascend/MindSpeed-LLM.git && \
@@ -180,16 +166,15 @@ RUN git clone https://gitcode.com/ascend/MindSpeed-LLM.git && \
180 cd ../MindSpeed-LLM && \166 cd ../MindSpeed-LLM && \
181 git checkout ${MINDSPEED_LLM_BRANCH} && \167 git checkout ${MINDSPEED_LLM_BRANCH} && \
182 mkdir logs && \168 mkdir logs && \
183- pip3 install -r requirements.txt169+ pip3 install --no-cache-dir -r requirements.txt
184 170 
185# Set working directory171# Set working directory
186WORKDIR /workspace/MindSpeed-LLM172WORKDIR /workspace/MindSpeed-LLM
187 173 
188# Auto-run on login174# Auto-run on login
189RUN echo 'cd /workspace/MindSpeed-LLM' >> /root/.bashrc && \175RUN echo 'cd /workspace/MindSpeed-LLM' >> /root/.bashrc && \
190- echo '. /opt/conda/etc/profile.d/conda.sh' >> /root/.bashrc && \176+ echo '[ -f /usr/local/Ascend/ascend-toolkit/set_env.sh ] && source /usr/local/Ascend/ascend-toolkit/set_env.sh' >> /root/.bashrc && \
191- echo 'conda activate base' >> /root/.bashrc177+ echo '[ -f /usr/local/Ascend/nnal/atb/set_env.sh ] && source /usr/local/Ascend/nnal/atb/set_env.sh' >> /root/.bashrc
192 178 
193-# Environment variables179+ # Environment variables
194-ENV PATH=/opt/conda/bin:$PATH
195ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit180ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit
@@ -9,24 +9,29 @@
9| **Source Repository** | [https://gitcode.com/Ascend/MindSpeed-LLM](https://gitcode.com/Ascend/MindSpeed-LLM) |9| **Source Repository** | [https://gitcode.com/Ascend/MindSpeed-LLM](https://gitcode.com/Ascend/MindSpeed-LLM) |
10| **Dockerfile Path** | `docker/Dockerfile` |10| **Dockerfile Path** | `docker/Dockerfile` |
11| **License** | Apache-2.0 |11| **License** | Apache-2.0 |
12+| **Where to get help** | [Issue Feedback](https://gitcode.com/Ascend/MindSpeed-LLM/issues) |
13+ 
14+## MindSpeed-LLM
15+ 
16+MindSpeed-LLM is a distributed training suite for large language models tailored to the Huawei Atlas ecosystem. It delivers end-to-end LLM training solutions for ecosystem partners of Huawei Atlas chips. The suite supports distributed pre-training and distributed instruction fine-tuning, and comes with a full development toolchain encompassing data preprocessing, weight conversion, online inference, baseline evaluation and more core capabilities.
12 17 
13## Image Tag Key Field Description18## Image Tag Key Field Description
14 19 
15-Image Tag naming format: `{MindSpeed LLM Version}-cann{CANN Version}-torch_npu{TorchNPU Version}-{ChipType}-{OS}-py{Python Version}-{Architecture}`20+Image Tag naming format: `v{MindSpeed LLM Version}-cann{CANN Version}-torch_npu{TorchNPU Version}-{ChipType}-{OS}-py{Python Version}-{Architecture}`
16 21 
17| Field | Description | Example Value |22| Field | Description | Example Value |
18| ------ | ------ | -------- |23| ------ | ------ | -------- |
19| MindSpeed LLM Version | MindSpeed LLM version label, also serves as Git branch name | `26.0.0` |24| MindSpeed LLM Version | MindSpeed LLM version label, also serves as Git branch name | `26.0.0` |
20-| CANNVersion | CANN base image version | `9.0.0` |25+| CANN Version | CANN base image version | `9.0.0` |
21-| TorchNPUVersion | TorchNPU version | `2.7.1` |26+| TorchNPU Version | TorchNPU version | `2.7.1` |
22-| ChipType | NPU chip type (lowercase) | `a3`, `910b` |27+| Chip Type | NPU chip type (lowercase) | `a3`, `910b` |
23| OS | Operating system version | `openeuler24.03`, `ubuntu22.04` |28| OS | Operating system version | `openeuler24.03`, `ubuntu22.04` |
24| Python Version | Python runtime version | `3.11` |29| Python Version | Python runtime version | `3.11` |
25| Architecture | CPU architecture type | `aarch64`, `x86_64` |30| Architecture | CPU architecture type | `aarch64`, `x86_64` |
26 31 
27### Tag Examples32### Tag Examples
28 33 
29-| Tag | MindSpeed LLM | CANN | torch-npu | NPU | OS | Python | Architecture |34+| Tag | MindSpeed LLM | CANN | TorchNPU | NPU | OS | Python | Architecture |
30| ----- | ----- | ----- | ----- | ----- | --------- | -------- | ------ |35| ----- | ----- | ----- | ----- | ----- | --------- | -------- | ------ |
31| `v26.0.0-cann9.0.0-torch_npu2.7.1-910b-openeuler24.03-py3.11-aarch64` | `v26.0.0` | `9.0.0` | `2.7.1` | `910b` | `openeuler24.03` | `3.11` | `aarch64` |36| `v26.0.0-cann9.0.0-torch_npu2.7.1-910b-openeuler24.03-py3.11-aarch64` | `v26.0.0` | `9.0.0` | `2.7.1` | `910b` | `openeuler24.03` | `3.11` | `aarch64` |
32| `v26.0.0-cann9.0.0-torch_npu2.7.1-910b-ubuntu22.04-py3.11-x86_64` | `v26.0.0` | `9.0.0` | `2.7.1` | `910b` | `ubuntu22.04` | `3.11` | `x86_64` |37| `v26.0.0-cann9.0.0-torch_npu2.7.1-910b-ubuntu22.04-py3.11-x86_64` | `v26.0.0` | `9.0.0` | `2.7.1` | `910b` | `ubuntu22.04` | `3.11` | `x86_64` |
@@ -63,14 +68,17 @@ The `image_build.sh` script supports flexible parameter configuration. Default v
63| ------ |-------------------------------------| ------------ |68| ------ |-------------------------------------| ------------ |
64| `-t, --npu-type` | NPU type:`a3` or `910b` | `910b` |69| `-t, --npu-type` | NPU type:`a3` or `910b` | `910b` |
65| `-o, --os` | OS:`openeuler24.03`or`ubuntu22.04` | `openeuler24.03` |70| `-o, --os` | OS:`openeuler24.03`or`ubuntu22.04` | `openeuler24.03` |
71+| `--no-cache` | Build without using Docker build cache | None |
66| `--mindspeed-llm-branch` |MindSpeed LLM version tag, also used as Git branch name | `26.0.0` |72| `--mindspeed-llm-branch` |MindSpeed LLM version tag, also used as Git branch name | `26.0.0` |
67| `--mindspeed-branch` | MindSpeed version tag, also used as Git branch name | `26.0.0_core_r0.12.1` |73| `--mindspeed-branch` | MindSpeed version tag, also used as Git branch name | `26.0.0_core_r0.12.1` |
68| `--megatron-branch` | Megatron-LM version tag, also used as Git branch name | `core_v0.12.1` |74| `--megatron-branch` | Megatron-LM version tag, also used as Git branch name | `core_v0.12.1` |
69| `--python-version` | Python version | `3.11` |75| `--python-version` | Python version | `3.11` |
70| `--torch-version` | PyTorch version | `2.7.1` |76| `--torch-version` | PyTorch version | `2.7.1` |
71| `--torch-npu-version` | TorchNPU version | `2.7.1` |77| `--torch-npu-version` | TorchNPU version | `2.7.1` |
78+| `--triton-ascend-version` | Triton-Ascend version | `3.2.1` |
72| `--base-image-version` | Base image CANN version | `9.0.0` |79| `--base-image-version` | Base image CANN version | `9.0.0` |
73| `--base-image` | Full base image name, passed as-is to pull the image if not empty | None |80| `--base-image` | Full base image name, passed as-is to pull the image if not empty | None |
81+| `--cleanup-on-fail` | Clean up dangling images/containers when build fails | None |
74 82 
75**Note:** The current NPU types are `910b` (Atlas A2 training products) and `a3` (Atlas A3 training products), `a5` (Ascend 950 training products)is pending.83**Note:** The current NPU types are `910b` (Atlas A2 training products) and `a3` (Atlas A3 training products), `a5` (Ascend 950 training products)is pending.
76 84 
@@ -194,9 +202,9 @@ docker run -it --rm \
194| ------ | ------ |202| ------ | ------ |
195| CANN | 9.0.0 |203| CANN | 9.0.0 |
196| Python | 3.11 |204| Python | 3.11 |
197-| Miniconda | 26.1.1-1 |
198| PyTorch | 2.7.1 |205| PyTorch | 2.7.1 |
199| TorchNPU | 2.7.1 |206| TorchNPU | 2.7.1 |
207+| Triton-Ascend | 3.2.1 |
200| MindSpeed LLM | 26.0.0 |208| MindSpeed LLM | 26.0.0 |
201 209 
202### Compatibility Change Notes210### Compatibility Change Notes
@@ -9,10 +9,15 @@
9| **源码仓库** | [https://gitcode.com/Ascend/MindSpeed-LLM](https://gitcode.com/Ascend/MindSpeed-LLM) |9| **源码仓库** | [https://gitcode.com/Ascend/MindSpeed-LLM](https://gitcode.com/Ascend/MindSpeed-LLM) |
10| **Dockerfile 路径** | `docker/Dockerfile` |10| **Dockerfile 路径** | `docker/Dockerfile` |
11| **许可证** | Apache-2.0 |11| **许可证** | Apache-2.0 |
12+| **问题反馈** | [Issue Feedback](https://gitcode.com/Ascend/MindSpeed-LLM/issues) |
13+ 
14+## MindSpeed-LLM
15+ 
16+MindSpeed LLM:基于昇腾生态的大语言模型分布式训练套件,旨在为华为昇腾芯片生态合作伙伴提供端到端的大语言模型训练方案,包含分布式预训练、分布式指令微调以及对应的开发工具链,如:数据预处理、权重转换、在线推理、基线评估等。
12 17 
13## 镜像 Tag 关键字段描述18## 镜像 Tag 关键字段描述
14 19 
15-镜像 Tag 命名遵循模板:`{MindSpeed LLM版本}-cann{CANN版本}-torch_npu{TorchNPU版本}-{芯片信息}-{操作系统}-py{Python版本}-{架构类型}`20+镜像 Tag 命名遵循模板:`v{MindSpeed LLM版本}-cann{CANN版本}-torch_npu{TorchNPU版本}-{芯片信息}-{操作系统}-py{Python版本}-{架构类型}`
16 21 
17| 字段 | 说明 | 示例值 |22| 字段 | 说明 | 示例值 |
18| ------ | ------ | -------- |23| ------ | ------ | -------- |
@@ -26,7 +31,7 @@
26 31 
27### 示例 Tag32### 示例 Tag
28 33 
29-| Tag | MindSpeed LLM | CANN | torch-npu | NPU | 操作系统 | Python | 架构 |34+| Tag | MindSpeed LLM | CANN | TorchNPU | NPU | 操作系统 | Python | 架构 |
30| ----- | ----- | ----- | ----- | ----- | --------- | -------- | ------ |35| ----- | ----- | ----- | ----- | ----- | --------- | -------- | ------ |
31| `v26.0.0-cann9.0.0-torch_npu2.7.1-910b-openeuler24.03-py3.11-aarch64` | `v26.0.0` | `9.0.0` | `2.7.1` | `910b` | `openeuler24.03` | `3.11` | `aarch64` |36| `v26.0.0-cann9.0.0-torch_npu2.7.1-910b-openeuler24.03-py3.11-aarch64` | `v26.0.0` | `9.0.0` | `2.7.1` | `910b` | `openeuler24.03` | `3.11` | `aarch64` |
32| `v26.0.0-cann9.0.0-torch_npu2.7.1-910b-ubuntu22.04-py3.11-x86_64` | `v26.0.0` | `9.0.0` | `2.7.1` | `910b` | `ubuntu22.04` | `3.11` | `x86_64` |37| `v26.0.0-cann9.0.0-torch_npu2.7.1-910b-ubuntu22.04-py3.11-x86_64` | `v26.0.0` | `9.0.0` | `2.7.1` | `910b` | `ubuntu22.04` | `3.11` | `x86_64` |
@@ -65,14 +70,17 @@ docker/
65| ------ |-------------------------------------| ------------ |70| ------ |-------------------------------------| ------------ |
66| `-t, --npu-type` | NPU 类型:`a3``910b` | `910b` |71| `-t, --npu-type` | NPU 类型:`a3``910b` | `910b` |
67| `-o, --os` | 操作系统:`openeuler24.03``ubuntu22.04` | `openeuler24.03` |72| `-o, --os` | 操作系统:`openeuler24.03``ubuntu22.04` | `openeuler24.03` |
73+| `--no-cache` | 构建时不使用 Docker 构建缓存 | 无 |
68| `--mindspeed-llm-branch` | MindSpeed LLM 版本标识,同时作为 Git 分支名称 | `26.0.0` |74| `--mindspeed-llm-branch` | MindSpeed LLM 版本标识,同时作为 Git 分支名称 | `26.0.0` |
69| `--mindspeed-branch` | MindSpeed 版本标识,同时作为 Git 分支名称 | `26.0.0_core_r0.12.1` |75| `--mindspeed-branch` | MindSpeed 版本标识,同时作为 Git 分支名称 | `26.0.0_core_r0.12.1` |
70| `--megatron-branch` | Megatron-LM 版本标识,同时作为 Git 分支名称 | `core_v0.12.1` |76| `--megatron-branch` | Megatron-LM 版本标识,同时作为 Git 分支名称 | `core_v0.12.1` |
71| `--python-version` | Python 版本 | `3.11` |77| `--python-version` | Python 版本 | `3.11` |
72| `--torch-version` | PyTorch 版本 | `2.7.1` |78| `--torch-version` | PyTorch 版本 | `2.7.1` |
73| `--torch-npu-version` | TorchNPU 版本 | `2.7.1` |79| `--torch-npu-version` | TorchNPU 版本 | `2.7.1` |
80+| `--triton-ascend-version` | Triton-Ascend 版本 | `3.2.1` |
74| `--base-image-version` | 基础镜像 CANN 版本 | `9.0.0` |81| `--base-image-version` | 基础镜像 CANN 版本 | `9.0.0` |
75| `--base-image` | 完整基础镜像名称,当设置不为空时会原样传入拉取镜像 | 无 |82| `--base-image` | 完整基础镜像名称,当设置不为空时会原样传入拉取镜像 | 无 |
83+| `--cleanup-on-fail` | 构建失败时清理悬空的镜像和容器 | 无 |
76 84 
77**提示:** 当前的NPU类型为 `910b`(Atlas A2 训练系列产品)和 `a3`(Atlas A3 训练系列产品),`a5`(Ascend 950 训练系列产品)待搭建。85**提示:** 当前的NPU类型为 `910b`(Atlas A2 训练系列产品)和 `a3`(Atlas A3 训练系列产品),`a5`(Ascend 950 训练系列产品)待搭建。
78 86 
@@ -196,9 +204,9 @@ docker run -it --rm \
196| ------ |----------|204| ------ |----------|
197| CANN | 9.0.0 |205| CANN | 9.0.0 |
198| Python | 3.11 |206| Python | 3.11 |
199-| Miniconda | 26.1.1-1 |
200| PyTorch | 2.7.1 |207| PyTorch | 2.7.1 |
201| TorchNPU | 2.7.1 |208| TorchNPU | 2.7.1 |
L
LLinShua7月28日

TorchNPU对应的版本号应该是26.0.0/26.1.0这种,后续排查整改

likedislike
209+| Triton-Ascend | 3.2.1 |
202| MindSpeed LLM | 26.0.0 |210| MindSpeed LLM | 26.0.0 |
203 211 
204### 兼容性说明212### 兼容性说明
@@ -37,6 +37,7 @@ BASE_IMAGE_VERSION="9.0.0"
37MINDSPEED_LLM_BRANCH="26.0.0"37MINDSPEED_LLM_BRANCH="26.0.0"
38MINDSPEED_BRANCH="26.0.0_core_r0.12.1"38MINDSPEED_BRANCH="26.0.0_core_r0.12.1"
39MEGATRON_BRANCH="core_v0.12.1"39MEGATRON_BRANCH="core_v0.12.1"
40+TRITON_ASCEND_VERSION="3.2.1"
40NO_CACHE=""41NO_CACHE=""
41NPU_TYPE_EXPLICIT=false42NPU_TYPE_EXPLICIT=false
42OS_EXPLICIT=false43OS_EXPLICIT=false
@@ -58,7 +59,7 @@ Optional:
58 -i, --image-name NAME Custom output image full name59 -i, --image-name NAME Custom output image full name
59 Default rule: mindspeed-llm:{version}-cann{cann_ver}-torch_npu{torch_npu_ver}-{chip}-{os}-py{py_ver}-{arch}60 Default rule: mindspeed-llm:{version}-cann{cann_ver}-torch_npu{torch_npu_ver}-{chip}-{os}-py{py_ver}-{arch}
60 -o, --os OS OS type: openEuler24.03 or ubuntu22.04 (default: openEuler24.03)61 -o, --os OS OS type: openEuler24.03 or ubuntu22.04 (default: openEuler24.03)
61- -n, --no-cache Build without using Docker build cache62+ --no-cache Build without using Docker build cache
62 --base-image IMAGE Full base image name, passed directly to FROM as-is63 --base-image IMAGE Full base image name, passed directly to FROM as-is
63 Example: swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:9.0.0-a3-openeuler24.03-py3.1164 Example: swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:9.0.0-a3-openeuler24.03-py3.11
64 --base-image-version VER CANN base image version (default: 9.0.0)65 --base-image-version VER CANN base image version (default: 9.0.0)
@@ -68,6 +69,7 @@ Optional:
68 --mindspeed-llm-branch MindSpeed-LLM git branch/version (default: 26.0.0)69 --mindspeed-llm-branch MindSpeed-LLM git branch/version (default: 26.0.0)
69 --mindspeed-branch MindSpeed git branch/version (default: 26.0.0_core_r0.12.1)70 --mindspeed-branch MindSpeed git branch/version (default: 26.0.0_core_r0.12.1)
70 --megatron-branch Megatron-LM git branch/version (default: core_v0.12.1)71 --megatron-branch Megatron-LM git branch/version (default: core_v0.12.1)
72+ --triton-ascend-version Triton-Ascend version (default: 3.2.1)
71 --cleanup-on-fail Clean up dangling <none> images/containers when build fails73 --cleanup-on-fail Clean up dangling <none> images/containers when build fails
72 -h, --help Show this help message and exit74 -h, --help Show this help message and exit
73 75 
@@ -121,10 +123,11 @@ while [[ $# -gt 0 ]]; do
121 -t|--npu-type) NPU_TYPE="$2"; NPU_TYPE_EXPLICIT=true; shift 2 ;;123 -t|--npu-type) NPU_TYPE="$2"; NPU_TYPE_EXPLICIT=true; shift 2 ;;
122 -i|--image-name) IMAGE_NAME="$2"; shift 2 ;;124 -i|--image-name) IMAGE_NAME="$2"; shift 2 ;;
123 -o|--os) OS="$2"; OS_EXPLICIT=true; shift 2 ;;125 -o|--os) OS="$2"; OS_EXPLICIT=true; shift 2 ;;
124- -n|--no-cache) NO_CACHE="--no-cache"; shift ;;126+ --no-cache) NO_CACHE="--no-cache"; shift ;;
125 --mindspeed-llm-branch) MINDSPEED_LLM_BRANCH="$2"; shift 2 ;;127 --mindspeed-llm-branch) MINDSPEED_LLM_BRANCH="$2"; shift 2 ;;
126 --mindspeed-branch) MINDSPEED_BRANCH="$2"; shift 2 ;;128 --mindspeed-branch) MINDSPEED_BRANCH="$2"; shift 2 ;;
127 --megatron-branch) MEGATRON_BRANCH="$2"; shift 2 ;;129 --megatron-branch) MEGATRON_BRANCH="$2"; shift 2 ;;
130+ --triton-ascend-version) TRITON_ASCEND_VERSION="$2"; shift 2 ;;
128 --base-image) BASE_IMAGE="$2"; shift 2 ;;131 --base-image) BASE_IMAGE="$2"; shift 2 ;;
129 --python-version) PYTHON_VERSION="$2"; PYTHON_VERSION_EXPLICIT=true; shift 2 ;;132 --python-version) PYTHON_VERSION="$2"; PYTHON_VERSION_EXPLICIT=true; shift 2 ;;
130 --torch-version) TORCH_VERSION="$2"; shift 2 ;;133 --torch-version) TORCH_VERSION="$2"; shift 2 ;;
@@ -205,6 +208,7 @@ BUILD_ARGS="$BUILD_ARGS --build-arg TORCH_NPU_VERSION=${TORCH_NPU_VERSION}"
205BUILD_ARGS="$BUILD_ARGS --build-arg MINDSPEED_LLM_BRANCH=${MINDSPEED_LLM_BRANCH}"208BUILD_ARGS="$BUILD_ARGS --build-arg MINDSPEED_LLM_BRANCH=${MINDSPEED_LLM_BRANCH}"
206BUILD_ARGS="$BUILD_ARGS --build-arg MINDSPEED_BRANCH=${MINDSPEED_BRANCH}"209BUILD_ARGS="$BUILD_ARGS --build-arg MINDSPEED_BRANCH=${MINDSPEED_BRANCH}"
207BUILD_ARGS="$BUILD_ARGS --build-arg MEGATRON_BRANCH=${MEGATRON_BRANCH}"210BUILD_ARGS="$BUILD_ARGS --build-arg MEGATRON_BRANCH=${MEGATRON_BRANCH}"
211+BUILD_ARGS="$BUILD_ARGS --build-arg TRITON_ASCEND_VERSION=${TRITON_ASCEND_VERSION}"
208 212 
209if [ -n "$BASE_IMAGE" ]; then213if [ -n "$BASE_IMAGE" ]; then
210 BUILD_ARGS="$BUILD_ARGS --build-arg BASE_IMAGE=${BASE_IMAGE}"214 BUILD_ARGS="$BUILD_ARGS --build-arg BASE_IMAGE=${BASE_IMAGE}"
@@ -230,6 +234,7 @@ echo "torch-npu Version: ${TORCH_NPU_VERSION}"
230echo "MindSpeed LLM Ver: ${MINDSPEED_LLM_BRANCH}"234echo "MindSpeed LLM Ver: ${MINDSPEED_LLM_BRANCH}"
231echo "MindSpeed Ver: ${MINDSPEED_BRANCH}"235echo "MindSpeed Ver: ${MINDSPEED_BRANCH}"
232echo "Megatron Ver: ${MEGATRON_BRANCH}"236echo "Megatron Ver: ${MEGATRON_BRANCH}"
237+echo "Triton-Ascend Ver: ${TRITON_ASCEND_VERSION}"
233echo "No Cache: ${NO_CACHE:-No}"238echo "No Cache: ${NO_CACHE:-No}"
234echo "=========================================="239echo "=========================================="
235 240