Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b25d374
feat: adapt upstream test CI workflows from v2.7.1 to v2.12.0
May 20, 2026
368cd0a
fix: remove pyg find-links from test requirements
May 20, 2026
7696403
Merge remote-tracking branch 'ascend/v2.12.0' into v2.12.0_dev
May 26, 2026
2fff038
adapt v2.12.0 CI workflows and docker images from v2.7.1
May 26, 2026
2b9999b
fix: use correct pytorch manylinux builder image tags for v2.12.0
May 26, 2026
30c271f
rename build-docker-images workflow to Build v2.12.0 Docker Images
May 26, 2026
3eaa815
fix: dynamically discover Python versions in builder Dockerfiles
May 26, 2026
f60258f
fix: add semicolons between for-loop body commands in builder Dockerf…
May 26, 2026
777f537
fix: install torch_geometric/torch-scatter with --no-build-isolation …
May 26, 2026
6589687
fix: skip Python 3.14+ in builder install loop
May 26, 2026
c7f97bb
fix: align dependency versions with upstream PyTorch v2.12.0
May 26, 2026
2331b4b
fix: pin torch_geometric==2.5.3 torch-scatter==2.1.2 from test/requir…
May 26, 2026
8ede2e4
align torchvision install with upstream: build from source via pinned…
May 26, 2026
b6918fd
switch torchvision back to pre-built CPU wheel
May 26, 2026
940c5d4
move torch_geometric to requirements-test.txt as pure Python wheel
May 26, 2026
b5b21dd
update builder image to latest build torch-npu-builder-aarch64-torch2…
May 26, 2026
beb375e
merge ascend/v2.12.0 into v2.12.0_dev, prefer ascend side on conflicts
May 26, 2026
3a4b3f9
restore test/requirements.txt to match ascend/v2.12.0
May 26, 2026
9980b9e
expand test whitelist and clean up blacklist in case_paths_ci.yml
May 26, 2026
cf2c14f
update test image to torch-npu-test-aarch64-cann-a3-py3.10-torch2.12.…
May 26, 2026
61c184d
add conftest.py.patch: inject import torch_npu before torch imports
May 26, 2026
5d5eeb2
fix: define HCCL constant in distributed_c10d.py.patch to prevent Nam…
May 26, 2026
b47f0d0
simplify torch_env_patch.sh: strict fail-fast, remove unused options
May 26, 2026
77e7ac5
trigger CI for v2.12.0 workflow validation
May 26, 2026
dc6ae65
fix: IndentationError in common_device_type.py.patch causing mass tes…
May 27, 2026
f6d27f3
fix: SyntaxError in common_methods_invocations.py.patch and TypeError…
May 27, 2026
c563b4e
fix: reorder hunks and fix line offsets in common_utils.py.patch
May 27, 2026
15a7cbe
fix: extend collect job timeout from 60 to 120 minutes
May 27, 2026
e031603
fix: hunk line count mismatch and blank context lines in common_utils…
May 28, 2026
2dfbef5
merge: integrate Ascend/pytorch v2.12.0 into v2.12.0_dev
May 28, 2026
59ef308
fix: two P0 case collection errors - onlyPRIVATEUSE1 import and get_d…
May 28, 2026
f7ec2d2
fix: blacklist cpython/3_13 tests and fix double-plus in test_ir_pass…
May 28, 2026
d23d98e
fix: revert SMxxOrLater changes in common_cuda.py.patch, keep only la…
May 28, 2026
9e85815
fix: add is not None guards to SMxxOrLater and missing onlyPRIVATEUSE…
May 28, 2026
236b49d
fix: set TORCH_NPU_DEVICE_CAPABILITY env var instead of monkey-patch
May 29, 2026
6e53c89
Merge remote-tracking branch 'ascend/v2.12.0' into v2.12.0_dev
May 29, 2026
290e654
fix: extend is not None guards to all SMxxOrLater variables in common…
May 29, 2026
d6b2443
fix: restore is not None guards for SM53/SM60/SM70OrLater in common_c…
May 29, 2026
4629e88
fix: add pipefail and --fuzz=5 to prevent silent patch failures
May 29, 2026
97dcc4f
Merge ascend/v2.12.0 into v2.12.0_dev
Jun 10, 2026
c71cfe8
ci: improve NPU test workflows with shard refactor, PR-based patch de…
Jun 10, 2026
6c11e31
refactor: rename apply_patch.sh to apply_test_patch.sh, remove --fuzz…
Jun 10, 2026
7b33c6c
fix: regenerate common_cuda.py.patch with correct unified diff line o…
Jun 10, 2026
3294dd0
Merge ascend/v2.12.0 into v2.12.0_dev
Jun 10, 2026
59a23bf
fix: add is not None guards to all SMxxOrLater and IS_SMxx variables …
Jun 11, 2026
d9f52c0
trigger: re-run CI workflow
Jun 15, 2026
8b791ad
merge: resolve conflicts, accept ascend/v2.12.0 NPU patch versions
Jun 15, 2026
8f3b1d5
switch distributed test runner from a3-16 to a3-8
Jun 15, 2026
4572133
fix: resolve 50 collection failures — patch fixes + blacklist
Jun 16, 2026
f188d5d
fix: test_misc.py.patch — correct hunk order and context
Jun 16, 2026
125622d
fix: test_aotdispatch.py.patch — add import torch as context line
Jun 16, 2026
48d2222
fix: test_future.py.patch — regenerate with diff -u for correct format
Jun 16, 2026
91fcfa1
fix: regenerate test_upstream patches — clean BOM, fix formatting, an…
Jun 23, 2026
a383095
merge: merge ascend/v2.12.0 into v2.12.0_dev
Jun 23, 2026
fed8aa0
fix: remove obsolete test_functions.py.patch — target code removed up…
Jun 23, 2026
b7a01eb
fix: remove 755 obsolete patches — target files deleted in upstream v…
Jun 23, 2026
de73675
Revert "fix: remove 755 obsolete patches — target files deleted in up…
Jun 23, 2026
0a3f302
Revert "fix: remove obsolete test_functions.py.patch — target code re…
Jun 23, 2026
b429c23
fix: regenerate test_functions and test_install_free_tensors patches …
Jun 23, 2026
04cf871
fix: clean BOM and trailing newlines in test_upstream patches
Jun 23, 2026
6d66240
fix: regenerate test_alias_analysis.py.patch — fix malformed hunk lin…
Jun 23, 2026
ea75f4c
fix: regenerate 9 failing patches against upstream pytorch v2.12.0
Jun 23, 2026
eb2ff52
fix: complete the patch for the distributed_c10d.py file
Jun 24, 2026
c69c682
fix: fix: Fixed the patch so it applies correctly without errors
Jun 24, 2026
07f2d98
fix:Fixed test_inductor_utils.py
Jun 24, 2026
f06711f
fix:还是用了72w用例运行成功的那一半进行修改了,先改了下 common_cuda.py.patch,看看是不是这个导致泛化增加的。
Jun 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
91 changes: 91 additions & 0 deletions .ci/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# torch-npu CI Docker Images

本目录管理 torch-npu 项目的 CI Docker 镜像,包括**构建镜像 (builder)** 和**测试镜像 (test)** 两类,每类分别支持 x86_64 和 aarch64 架构。

## 镜像类型

| 类型 | 基座 | 用途 |
|------|------|------|
| **builder** | manylinux2_28-builder | 编译构建 torch-npu wheel 包,包含完整编译工具链 |
| **test** | ubuntu:22.04 | CI 单元测试运行环境,包含 PyTorch CPU、CANN runtime、triton-ascend 和测试框架 |

## 目录结构

```
.ci/docker/
├── README.md
├── requirements-builder.txt # Builder 镜像 pip 依赖
├── requirements-test.txt # Test 镜像 pip 依赖
├── docker_build.sh # 构建入口脚本
├── common/ # 共享安装脚本
│ ├── install_cann.sh # 安装 CANN toolkit (支持 A1/A2/A3)
│ ├── install_triton.sh # 安装 triton-ascend (需传 Python 版本)
│ ├── install_obs.sh # 安装华为 OBS util
├── builder/
│ ├── Dockerfile.x86_64
│ └── Dockerfile.aarch64
└── test/
├── Dockerfile.x86_64
└── Dockerfile.aarch64
```

## 快速构建

```bash
# Builder 镜像 (不含 CANN)
./docker_build.sh torch-npu-builder-x86_64-torch2.12.0
./docker_build.sh torch-npu-builder-aarch64-torch2.12.0

# Test 镜像 (含 CANN)
./docker_build.sh torch-npu-test-x86_64-cann-a1-py3.10-torch2.12.0
./docker_build.sh torch-npu-test-aarch64-cann-a2-py3.10-torch2.12.0
```

## Tag 命名规范

参考上游 PyTorch `pytorch-linux-jammy-cuda12.4-cudnn9-py3-gcc11` 模式,tag 即为最终镜像名:

**Builder**(不含 CANN):
```
torch-npu-builder-<ARCH>-torch<PYTORCH_VERSION>
```
```
./docker_build.sh torch-npu-builder-x86_64-torch2.12.0
# ^ ^ ^ ^
# | | | └── PyTorch 版本 (torch2.12.0)
# | | └── 架构
# | └── 镜像类型
# └── 固定前缀
```

**Test**(含 CANN runtime):
```
torch-npu-test-<ARCH>-cann<CHIP>-py<PYTHON_VERSION>-torch<PYTORCH_VERSION>
```
```
./docker_build.sh torch-npu-test-x86_64-cann-a1-py3.10-torch2.12.0
# ^ ^ ^ ^ ^ ^ ^
# | | | | | | └── PyTorch 版本
# | | | | | └── torch 前缀
# | | | | └── Python 版本
# | | | └── py 前缀
# | | └── CANN 芯片 (A1/A2/A3)
# | └── 架构
# └── 镜像类型
```

| 字段 | 可选值 |
|------|--------|
| IMAGE_TYPE | builder, test |
| ARCH | x86_64, aarch64 |
| CHIP | A1 (Ascend 910), A2 (Ascend 910b), A3 (仅 test) |
| PYTHON_VERSION | 3.10 (仅 test) |
| PYTORCH_VERSION | 2.12.0 |

## CANN 芯片映射

| CANN_CHIP | 芯片 | CANN 版本 |
|-----------|------|----------|
| A1 | Ascend 910 | 9.1.0 |
| A2 | Ascend 910b | 8.5.0 (x86_64) / 9.1.0 (aarch64) |
| A3 | Ascend A3 | 9.0.0-beta.1 (x86_64) / 9.0.0-beta.2 (aarch64) |
85 changes: 85 additions & 0 deletions .ci/docker/builder/Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
FROM pytorch/manylinux2_28_aarch64-builder:cpu-aarch64-v2.12.0-rc9

ARG PYTORCH_VERSION=2.12.0

ENV PATH=/usr/local/bin:$PATH
ENV AUDITWHEEL_PLAT=manylinux_2_28_aarch64
ENV ETCD_UNSUPPORTED_ARCH=arm64
ENV PYTORCH_VERSION=${PYTORCH_VERSION}

COPY requirements-builder.txt /opt/buildtools/

# Dynamically discover available cpython versions and create pip/python symlinks.
# The base manylinux image provides /opt/_internal/cpython-X.Y.Z/ for each Python.
RUN set -e; cd /usr/local/bin \
&& for cpython_dir in /opt/_internal/cpython-3.*/; do \
py_ver=$(basename "$cpython_dir" | sed 's/cpython-//'); \
major_minor=$(echo "$py_ver" | grep -oP '^\d+\.\d+'); \
pybin="${cpython_dir}bin/python${major_minor}"; \
pipbin="${cpython_dir}bin/pip${major_minor}"; \
[ -f "$pybin" ] && ln -sf "$pybin" "python${major_minor}"; \
[ -f "$pipbin" ] && ln -sf "$pipbin" "pip${major_minor}"; \
echo "Registered Python ${major_minor} (${py_ver})"; \
done \
&& ln -sf python3.10 python3 \
&& ln -sf pip3.10 pip3 \
&& echo "Default python: $(python3 --version)" \
&& echo "Default pip: $(pip3 --version)"

# Set pip source
RUN mkdir /root/.pip \
&& echo "[global]" > /root/.pip/pip.conf \
&& echo "index-url=https://mirrors.huaweicloud.com/repository/pypi/simple" >> /root/.pip/pip.conf \
&& echo "trusted-host=mirrors.huaweicloud.com" >> /root/.pip/pip.conf \
&& echo "timeout=120" >> /root/.pip/pip.conf

# Install PyTorch, build deps, and requirements for each python version.
# Only install on Python 3.10-3.13; skip 3.14+ (torch 2.12 has no wheels for 3.14).
RUN for pp in $(ls /usr/local/bin/pip3.* 2>/dev/null | grep -oP 'pip\d+\.\d+' | sort -V); do \
pyver=${pp#pip}; \
case "$pyver" in \
3.9|3.10|3.11|3.12|3.13) ;; \
*) echo "=== Skipping ${pp} (Python ${pyver} not supported by torch 2.12) ==="; continue ;; \
esac; \
echo "=== Installing PyTorch ${PYTORCH_VERSION} for ${pp} ==="; \
$pp install --no-cache-dir torch==${PYTORCH_VERSION} --extra-index-url https://download.pytorch.org/whl/cpu \
-r /opt/buildtools/requirements-builder.txt; \
done \
&& echo "=== PyTorch installation complete ===" \
&& auditwheel_bin=$(find /opt/_internal/cpython-3.1*/bin/auditwheel 2>/dev/null | tail -1) \
&& if [ -n "$auditwheel_bin" ]; then \
ln -sf "$auditwheel_bin" /usr/local/bin/auditwheel; \
echo "auditwheel linked from ${auditwheel_bin}"; \
fi

# Install system build tools
RUN echo "alias ll='ls -l --color=auto'" >> /root/.bashrc \
&& yum install -y vim-common --disablerepo=ius \
&& yum install -y ninja-build binutils lld mold dos2unix gcc gcc-c++ make cmake3 wget tar unzip elfutils java-1.8.0-openjdk-devel \
&& cd /tmp \
&& wget https://github.com/ccache/ccache/releases/download/v4.10/ccache-4.10.tar.gz \
&& tar -xzf ccache-4.10.tar.gz \
&& cd ccache-4.10 \
&& mkdir build \
&& cd build \
&& cmake3 .. \
&& make -j$(nproc) \
&& make install \
&& cd /tmp \
&& rm -rf ccache-4.10* \
&& ccache --version \
&& wget https://github.com/etcd-io/etcd/releases/download/v3.4.3/etcd-v3.4.3-linux-arm64.tar.gz \
&& tar -zxf etcd-v3.4.3-linux-arm64.tar.gz \
&& mv etcd-v3.4.3-linux-arm64/etcd /usr/local/bin/ \
&& pip3.10 install python-etcd \
&& etcd --version \
&& yum update -y \
&& yum clean all

# Set timezone
RUN rm -f /etc/localtime \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo 'Asia/Shanghai' >/etc/timezone \
&& echo "export TZ='Asia/Shanghai'" >>/etc/profile

WORKDIR /home
97 changes: 97 additions & 0 deletions .ci/docker/builder/Dockerfile.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
FROM pytorch/manylinux2_28-builder:cpu-v2.12.0-rc9

ARG PYTORCH_VERSION=2.12.0

ENV PATH=/usr/local/bin:$PATH
ENV AUDITWHEEL_PLAT=manylinux_2_28_x86_64
ENV PYTORCH_VERSION=${PYTORCH_VERSION}

COPY requirements-builder.txt /opt/buildtools/

# Dynamically discover available cpython versions and create pip/python symlinks.
# The base manylinux image provides /opt/_internal/cpython-X.Y.Z/ for each Python.
RUN set -e; cd /usr/local/bin \
&& for cpython_dir in /opt/_internal/cpython-3.*/; do \
py_ver=$(basename "$cpython_dir" | sed 's/cpython-//'); \
major_minor=$(echo "$py_ver" | grep -oP '^\d+\.\d+'); \
pybin="${cpython_dir}bin/python${major_minor}"; \
pipbin="${cpython_dir}bin/pip${major_minor}"; \
[ -f "$pybin" ] && ln -sf "$pybin" "python${major_minor}"; \
[ -f "$pipbin" ] && ln -sf "$pipbin" "pip${major_minor}"; \
echo "Registered Python ${major_minor} (${py_ver})"; \
done \
&& ln -sf python3.10 python3 \
&& ln -sf pip3.10 pip3 \
&& echo "Default python: $(python3 --version)" \
&& echo "Default pip: $(pip3 --version)"

# Set pip source
RUN mkdir /root/.pip \
&& echo "[global]" > /root/.pip/pip.conf \
&& echo "index-url=https://mirrors.huaweicloud.com/repository/pypi/simple" >> /root/.pip/pip.conf \
&& echo "trusted-host=mirrors.huaweicloud.com" >> /root/.pip/pip.conf \
&& echo "timeout=120" >> /root/.pip/pip.conf

# Install PyTorch, build deps, and requirements for each python version.
# x86_64 uses +cpu suffix to avoid pulling CUDA builds from PyPI.
# Only install on Python 3.10-3.13; skip 3.14+ (torch 2.12 has no wheels for 3.14).
RUN for pp in $(ls /usr/local/bin/pip3.* 2>/dev/null | grep -oP 'pip\d+\.\d+' | sort -V); do \
pyver=${pp#pip}; \
case "$pyver" in \
3.9|3.10|3.11|3.12|3.13) ;; \
*) echo "=== Skipping ${pp} (Python ${pyver} not supported by torch 2.12) ==="; continue ;; \
esac; \
echo "=== Installing PyTorch ${PYTORCH_VERSION}+cpu for ${pp} ==="; \
$pp install --no-cache-dir torch==${PYTORCH_VERSION}+cpu --extra-index-url https://download.pytorch.org/whl/cpu \
-r /opt/buildtools/requirements-builder.txt; \
done \
&& echo "=== PyTorch installation complete ===" \
&& auditwheel_bin=$(find /opt/_internal/cpython-3.1*/bin/auditwheel 2>/dev/null | tail -1) \
&& if [ -n "$auditwheel_bin" ]; then \
ln -sf "$auditwheel_bin" /usr/local/bin/auditwheel; \
echo "auditwheel linked from ${auditwheel_bin}"; \
fi

# Install system build tools
RUN yum remove -y ius-release epel-release 2>/dev/null || true \
&& rm -rf /etc/yum.repos.d/ius*.repo /etc/yum.repos.d/epel*.repo \
&& yum clean all && rm -rf /var/cache/dnf /var/cache/yum \
&& echo "alias ll='ls -l --color=auto'" >> /root/.bashrc \
&& yum install -y vim-common --disablerepo=ius \
&& yum install -y binutils lld dos2unix gcc gcc-c++ make cmake3 wget tar unzip elfutils java-1.8.0-openjdk-devel \
&& cd /tmp \
&& wget -q https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip \
&& unzip ninja-linux.zip \
&& cp ninja /usr/local/bin/ && chmod +x /usr/local/bin/ninja \
&& cd /tmp \
&& wget -q https://github.com/rui314/mold/archive/refs/tags/v2.32.1.tar.gz \
&& tar -xf v2.32.1.tar.gz \
&& cd mold-2.32.1 \
&& cmake -DCMAKE_BUILD_TYPE=Release -DMOLD_MOSTLY_STATIC=ON . \
&& make -j$(nproc) && make install \
&& cd /tmp \
&& wget https://github.com/ccache/ccache/releases/download/v4.10/ccache-4.10.tar.gz \
&& tar -xzf ccache-4.10.tar.gz \
&& cd ccache-4.10 \
&& mkdir build \
&& cd build \
&& cmake3 .. \
&& make -j$(nproc) \
&& make install \
&& cd /tmp && rm -rf /tmp/* \
&& ninja --version && mold --version && ccache --version \
&& wget https://github.com/etcd-io/etcd/releases/download/v3.4.3/etcd-v3.4.3-linux-amd64.tar.gz \
&& tar -zxf etcd-v3.4.3-linux-amd64.tar.gz \
&& mv etcd-v3.4.3-linux-amd64/etcd /usr/local/bin/ \
&& pip3.10 install python-etcd \
&& etcd --version \
&& yum clean all \
&& yum update -y

# Set timezone
RUN rm -f /etc/localtime \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo 'Asia/Shanghai' >/etc/timezone \
&& echo "export TZ='Asia/Shanghai'" >>/etc/profile

WORKDIR /home
109 changes: 109 additions & 0 deletions .ci/docker/common/install_cann.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/bash
# Install CANN toolkit for Ascend NPU.
# Usage: CANN_CHIP=A1 ./install_cann.sh
# CANN_CHIP: A1 (Ascend 910), A2 (Ascend 910b), A3 (Ascend A3)
# Automatically detects architecture (x86_64 / aarch64).

set -e

CANN_CHIP="${CANN_CHIP:-A1}"
ARCH=$(uname -m)

BASE_URL="https://pytorch-package.obs.cn-north-4.myhuaweicloud.com/pta/cann-package"
CANN_BASE_URL="https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%209.1.T1"

case "${ARCH}_${CANN_CHIP}" in
# x86_64
x86_64_A1)
TOOLKIT_URL="${BASE_URL}/20260513/Ascend-cann-toolkit_9.1.0_linux-x86_64.run"
OPS_URL="${BASE_URL}/20260513/Ascend-cann-910-ops_9.1.0_linux-x86_64.run"
NNAL_URL="${BASE_URL}/20260513/Ascend-cann-nnal_9.1.0_linux-x86_64.run"
OPS_GLOB="Ascend-cann-910*"
SET_ENV_PATH="/usr/local/Ascend/cann/set_env.sh"
;;
x86_64_A2)
TOOLKIT_URL="${CANN_BASE_URL}/Ascend-cann-toolkit_9.1.0-beta.1_linux-x86_64.run"
OPS_URL="${CANN_BASE_URL}/Ascend-cann-910b-ops_9.1.0-beta.1_linux-x86_64.run"
NNAL_URL="${CANN_BASE_URL}/Ascend-cann-nnal_9.1.0-beta.1_linux-x86_64.run"
OPS_GLOB="Ascend-cann-910b-ops*"
SET_ENV_PATH="/usr/local/Ascend/cann/set_env.sh"
;;
x86_64_A3)
TOOLKIT_URL="${CANN_BASE_URL}/Ascend-cann-toolkit_9.1.0-beta.1_linux-x86_64.run"
OPS_URL="${CANN_BASE_URL}/Ascend-cann-A3-ops_9.1.0-beta.1_linux-x86_64.run"
NNAL_URL="${CANN_BASE_URL}/Ascend-cann-nnal_9.1.0-beta.1_linux-x86_64.run"
OPS_GLOB="Ascend-cann-A3-ops*"
SET_ENV_PATH="/usr/local/Ascend/cann/set_env.sh"
;;
# aarch64
aarch64_A1)
TOOLKIT_URL="${BASE_URL}/20260302/Ascend-cann-toolkit_9.0.0-beta.1_linux-aarch64.run"
OPS_URL="${BASE_URL}/20260302/Ascend-cann-910b-ops_9.0.0-beta.1_linux-aarch64.run"
NNAL_URL="${BASE_URL}/20260302/Ascend-cann-nnal_9.0.0-beta.1_linux-aarch64.run"
OPS_GLOB="Ascend-cann-910b*"
SET_ENV_PATH="/usr/local/Ascend/cann/set_env.sh"
;;
aarch64_A2)
TOOLKIT_URL="${CANN_BASE_URL}/Ascend-cann-toolkit_9.1.0-beta.1_linux-aarch64.run"
OPS_URL="${CANN_BASE_URL}/Ascend-cann-910b-ops_9.1.0-beta.1_linux-aarch64.run"
NNAL_URL="${CANN_BASE_URL}/Ascend-cann-nnal_9.1.0-beta.1_linux-aarch64.run"
OPS_GLOB="Ascend-cann-910b-ops*"
SET_ENV_PATH="/usr/local/Ascend/cann/set_env.sh"
;;
aarch64_A3)
TOOLKIT_URL="${CANN_BASE_URL}/Ascend-cann-toolkit_9.1.0-beta.1_linux-aarch64.run"
OPS_URL="${CANN_BASE_URL}/Ascend-cann-A3-ops_9.1.0-beta.1_linux-aarch64.run"
NNAL_URL="${CANN_BASE_URL}/Ascend-cann-nnal_9.1.0-beta.1_linux-aarch64.run"
OPS_GLOB="Ascend-cann-A3-ops*"
SET_ENV_PATH="/usr/local/Ascend/cann/set_env.sh"
;;
*)
echo "Unsupported combination: ${ARCH} + ${CANN_CHIP}"
exit 1
;;
esac

echo "Installing CANN ${CANN_CHIP} for ${ARCH}..."

echo "=== Creating HwHiAiUser user and group ==="
groupadd -f HwHiAiUser
id -u HwHiAiUser >/dev/null 2>&1 || useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash

rm -rf cann
mkdir -p cann && cd cann

echo "=== Downloading CANN packages ==="
curl -O "${TOOLKIT_URL}"
curl -O "${OPS_URL}"
curl -O "${NNAL_URL}"
echo "Download complete."

chmod +x Ascend-cann*.run

echo "=== Installing CANN toolkit ==="
./Ascend-cann-toolkit*.run --full --quiet --install-path=/usr/local/Ascend
source "${SET_ENV_PATH}"
echo "toolkit install success"

echo "=== Installing CANN ops ==="
./${OPS_GLOB}.run --install --quiet --install-path=/usr/local/Ascend
echo "ops install success"

echo "=== Installing CANN nnal ==="
./Ascend-cann-nnal*.run --install --quiet --install-path=/usr/local/Ascend
source /usr/local/Ascend/nnal/atb/set_env.sh
echo "nnal install success"

# Some CANN versions install to versioned paths (e.g. cann-9.0.0-beta.2)
# instead of /usr/local/Ascend/cann/. Fix broken symlinks so runtime
# sourcing of set_env.sh works.
if [ ! -f /usr/local/Ascend/cann/set_env.sh ]; then
CANN_REAL_DIR=$(ls -d /usr/local/Ascend/cann-* 2>/dev/null | head -1)
if [ -n "${CANN_REAL_DIR}" ]; then
ln -sf "${CANN_REAL_DIR}" /usr/local/Ascend/cann
echo "Fixed: linked ${CANN_REAL_DIR} -> /usr/local/Ascend/cann"
fi
fi

rm -rf *
echo "CANN ${CANN_CHIP} installation complete."
Loading
Loading