Install the complete CANN components (Toolkit, Kernels, NNAL) into a specified path in an Ascend NPU environment.
Core Principle: The installation order must be Toolkit → Kernels → NNAL and cannot be reversed. NNAL depends on the Toolkit's environment variables.
When to Invoke
- The user requests installation of CANN (including toolkit, kernels, nnal)
- The user needs to install CANN to a custom path
- The user is setting up an Ascend development environment in a Docker container
- The user needs to install a specific version of CANN (such as 9.0.0-beta.2)
Pre-checks
Step 1: Check the NPU driver
npu-smi info
Expected result: Output NPU device information (chip model, VRAM, etc.).
Exception handling: If command not found, the Ascend driver and firmware need to be installed first; refer to the ascend-npu-driver-install skill.
Step 2: Confirm the chip model
Obtain the chip model from the npu-smi info output to select the corresponding Kernels package:
| Chip Model | Kernels Package Name Suffix |
|---|---|
| 910B / 910B3 | 910b |
| 910 | 910 |
| 310P | 310p |
| 310B | 310b |
Step 3: Confirm the system architecture
uname -m
aarch64: ARM architecture, select_linux-aarch64.runx86_64: x86 architecture, select_linux-x86_64.run
Installation Method 1: Download run packages from the official website for installation
Step 4: Obtain the CANN installation packages
Visit the Ascend Community Download Center to obtain the installation packages:
https://www.hiascend.com/developer/download/community/result?module=cann&cann=<版本号>
Packages to download(3):
| Package Name | Format | Description |
|---|---|---|
Ascend-cann-toolkit_<版本>_linux-<架构>.run |
run package | Development toolkit (must be installed first) |
Ascend-cann-kernels-<芯片>_<版本>_linux-<架构>.run |
run package | Operator library (depends on Toolkit) |
Ascend-cann-nnal_<版本>_linux-<架构>.run |
run package | Acceleration library (depends on Toolkit environment variables) |
Note: The official website download links require login authentication and cannot be directly wget. Alternatives:
- Download after logging in through a browser, then upload to the server
- Use "Method 2: Extract from Docker image" below
Step 5: Install Toolkit
INSTALL_PATH="<用户指定安装路径>"
chmod +x Ascend-cann-toolkit_*.run
./Ascend-cann-toolkit_*.run --install --install-path="${INSTALL_PATH}"
Default path:/usr/local/Ascend
Custom path example:/home/user/run/cann900beta2
Step 6: Install Kernels
chmod +x Ascend-cann-kernels-*.run
./Ascend-cann-kernels-*.run --install --install-path="${INSTALL_PATH}"
Step 7: Configure Toolkit environment variables (prerequisite for NNAL installation)
source "${INSTALL_PATH}/ascend-toolkit/set_env.sh"
Key: The NNAL installation script depends on environment variables such as ASCEND_TOOLKIT_HOME , so they must be sourced first.
Step 8: Install NNAL
chmod +x Ascend-cann-nnal_*.run
./Ascend-cann-nnal_*.run --install --install-path="${INSTALL_PATH}"
Installation Method 2: Extract from Docker image
When the run packages cannot be downloaded directly, the installed CANN files can be extracted from Huawei's official CANN Docker image.
Step 4: Confirm the local image
docker images | grep cann
Huawei official CANN image tag format:quay.io/ascend/cann:<版本>-<芯片>-<OS>-py<Python版本>
Example:quay.io/ascend/cann:9.0.0-beta.2-910-openeuler24.03-py3.11
If there is no local image, pull it first:
docker pull quay.io/ascend/cann:9.0.0-beta.2-910-openeuler24.03-py3.11
Step 5: Create a temporary container and extract the files
INSTALL_PATH="<用户指定安装路径>"
CANN_IMAGE="quay.io/ascend/cann:9.0.0-beta.2-910-openeuler24.03-py3.11"
docker create --name cann_temp "${CANN_IMAGE}"
docker cp cann_temp:/usr/local/Ascend/cann-9.0.0-beta.2 "${INSTALL_PATH}/"
docker cp cann_temp:/usr/local/Ascend/nnal "${INSTALL_PATH}/"
docker rm cann_temp
Directory structure inside the image:
| Path inside the image | Content | Target path |
|---|---|---|
/usr/local/Ascend/cann-<版本>/ |
Toolkit + Kernels | ${INSTALL_PATH}/cann-<版本>/ |
/usr/local/Ascend/nnal/ |
NNAL (atb acceleration library) | ${INSTALL_PATH}/nnal/ |
Step 6: Fix the hardcoded paths in set_env.sh
The set_env.sh in the Docker image contains hardcoded paths /usr/local/Ascend/cann-<版本>, which need to be replaced with the actual installation paths:
sed -i "s|/usr/local/Ascend/cann-<版本>|${INSTALL_PATH}/cann-<版本>|g" \
"${INSTALL_PATH}/cann-<版本>/set_env.sh"
Also check for hardcoded paths in other scripts:
grep -rl '/usr/local/Ascend/cann-<版本>' "${INSTALL_PATH}/" --include='*.sh' | \
xargs sed -i "s|/usr/local/Ascend/cann-<版本>|${INSTALL_PATH}/cann-<版本>|g"
Environment variable configuration
Step 9: Load environment variables
source "${INSTALL_PATH}/cann-<版本>/set_env.sh"
source "${INSTALL_PATH}/nnal/atb/set_env.sh"
Persistent configuration(write to the shell configuration file):
cat >> ~/.bashrc << EOF
source ${INSTALL_PATH}/cann-<版本>/set_env.sh
source ${INSTALL_PATH}/nnal/atb/set_env.sh
EOF
Environment variable description
| Variable name | Source | Description |
|---|---|---|
ASCEND_TOOLKIT_HOME |
toolkit set_env.sh | Toolkit installation root path |
ASCEND_HOME_PATH |
toolkit set_env.sh | Same as ASCEND_TOOLKIT_HOME |
ASCEND_OPP_PATH |
toolkit set_env.sh | OPP operator path |
ATB_HOME_PATH |
nnal atb set_env.sh | ATB acceleration library path |
LD_LIBRARY_PATH |
Two set_env.sh | Dynamic library search path |
PYTHONPATH |
toolkit set_env.sh | Python module search path |
Installation verification
Step 10: Verify installation integrity
source "${INSTALL_PATH}/cann-<版本>/set_env.sh"
source "${INSTALL_PATH}/nnal/atb/set_env.sh"
echo "=== Toolkit Version ==="
cat "${INSTALL_PATH}/cann-<版本>/<架构>-linux/ascend_toolkit_install.info" | grep version
echo "=== Kernels Version ==="
cat "${INSTALL_PATH}/cann-<版本>/<架构>-linux/ascend_ops_install.info" | grep version
echo "=== NNAL Version ==="
cat "${INSTALL_PATH}/nnal/atb/latest/version.info"
echo "=== Key Binaries ==="
which bisheng && echo "bisheng OK"
which atc && echo "atc OK"
echo "=== Environment Variables ==="
echo "ASCEND_TOOLKIT_HOME=${ASCEND_TOOLKIT_HOME}"
echo "ATB_HOME_PATH=${ATB_HOME_PATH}"
echo "=== NPU Status ==="
npu-smi info | head -5
Verification checklist
- Toolkit version information is correct
- Kernels(ops) version information is correct
- NNAL(atb) version information is correct
-
bishengcommand is available -
atccommand is available -
ASCEND_TOOLKIT_HOMEpoints to the correct path -
ATB_HOME_PATHpoints to the correct path -
npu-smi infodevice information is output normally
Installation verification report format
CANN INSTALLATION REPORT
========================
Install Path: <安装路径>
Toolkit: <版本号>
Kernels: <版本号>
NNAL: <版本号>
Architecture: <aarch64/x86_64>
Chip: <芯片型号>
VERDICT: SUCCESS / PARTIAL / FAILED
CHECKS:
[1] Toolkit installed: PASS / FAIL
[2] Kernels installed: PASS / FAIL
[3] NNAL installed: PASS / FAIL
[4] Environment vars: PASS / FAIL
[5] bisheng available: PASS / FAIL
[6] atc available: PASS / FAIL
[7] NPU accessible: PASS / FAIL
ISSUES: <count>
[CRITICAL] <finding>
[WARNING] <finding>
Common issues
1. Insufficient permissions reported when installing the run package
Cause: Insufficient permissions on the installation directory.
Solution:
chmod 755 <安装路径的父目录>
2. NNAL installation failed, reporting that the Toolkit environment variables cannot be found
Cause: The Toolkit's set_env.sh was not sourced first.
Solution:
source "${INSTALL_PATH}/ascend-toolkit/set_env.sh"
# 或(Docker镜像提取方式)
source "${INSTALL_PATH}/cann-<版本>/set_env.sh"
3. The bisheng/atc command cannot be found after extracting the Docker image
Cause: The paths in set_env.sh have not been corrected.
Solution: Run the sed command in Step 6 to replace the hardcoded paths.
4. The official website download link cannot be wget directly
Cause: The Ascend community download links require login authentication, and the URLs stored in OBS carry signatures and expiration times.
Solution: Use "Method 2: Extract from the Docker image".
5. The Kernels package name does not match the chip model
Cause: For the 910B chip, select the kernels package with the 910b suffix, not 910。
Solution: Select the correct kernels package based on the chip model confirmed in Step 2.
Precautions
- Installation order: Must be Toolkit → Kernels → NNAL, and the order cannot be reversed
- Environment variables: Before installing NNAL, you must first source the Toolkit's set_env.sh
- Path consistency: The three components must be installed under the same path
- Version matching: The Toolkit, Kernels, and NNAL versions must be consistent
- Driver compatibility: The CANN version must be compatible with the host NPU driver version