Guides installation of CANN (neural-network computing architecture) on Ascend NPU platforms. Covers driver checks, offline/online install methods, environment variables, and verification.
Ships in external-gitcode-ascend-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
此技能为在昇腾NPU平台上安装CANN(神经网络计算架构)提供全面指导。
在以下情况下调用此技能:
硬件要求
驱动检查命令
npu-smi info
检查结果
检查CANN安装依赖(Python和pip)是否已安装:
# 检查Python
if ! command -v python3 &> /dev/null && ! command -v python &> /dev/null; then
echo "Python not found, please install from env_dependence.md"
fi
# 检查pip
if ! command -v pip3 &> /dev/null && ! command -v pip &> /dev/null; then
echo "pip not found, please install from env_dependence.md"
fi
如果任何依赖缺少,会显示提示信息,请参考 环境依赖安装指南 进行安装。
步骤3.1:检查当前文件夹是否存在安装包
# 检查当前文件夹是否存在CANN安装包
if ls Ascend-cann-toolkit_*.run 2>/dev/null | grep -q .; then
echo "找到CANN Toolkit安装包"
TOOLKIT_PACKAGE=$(ls Ascend-cann-toolkit_*.run)
else
echo "未找到CANN Toolkit安装包,请使用在线安装方式"
# 退出离线安装,建议使用在线安装
exit 1
fi
# 检查当前文件夹是否存在ops安装包
if ls Ascend-cann-*-ops_*.run 2>/dev/null | grep -q .; then
echo "找到CANN ops安装包"
OPS_PACKAGE=$(ls Ascend-cann-*-ops_*.run)
else
echo "未找到CANN ops安装包,请使用在线安装方式"
# 退出离线安装,建议使用在线安装
exit 1
fi
步骤3.2:安装CANN
重要:必须先安装Toolkit,再安装ops
run格式安装:
# 安装 Toolkit (默认路径 /usr/local/Ascend)
bash "$TOOLKIT_PACKAGE" --install --quiet
# 安装 ops
bash "$OPS_PACKAGE" --install --quiet
注意:conda主要用于创建Python虚拟环境,CANN工具包仍需通过离线安装包安装。
步骤3.1:创建conda虚拟环境
# 创建Python环境(CANN支持Python 3.7.x - 3.13.11)
conda create -n cann_env python
# 激活环境
conda activate cann_env
步骤3.2:配置昇腾conda官方源
# 添加昇腾conda源
conda config --add channels https://repo.huaweicloud.com/ascend/repos/conda
步骤3.3:安装CANN包
# 使用conda安装CANN工具包
conda install ascend::cann-toolkit
# 安装CANN ops包(根据芯片类型选择,如910、910b、310等)
conda install ascend::cann-{芯片类型}-ops
步骤3.1:配置华为官方源
sudo curl https://repo.oepkgs.net/ascend/cann/ascend.repo -o /etc/yum.repos.d/ascend.repo && yum makecache
步骤3.2:安装CANN包
yum install -y Ascend-cann-toolkit
yum install -y Ascend-cann-{芯片类型}-ops
临时设置(仅当前终端生效)
source /usr/local/Ascend/ascend-toolkit/set_env.sh
永久设置(写入Shell配置文件)
echo "source /usr/local/Ascend/ascend-toolkit/set_env.sh" >> ~/.bashrc
使用Python验证ACL接口
python3 -c "import acl;acl.init();acl.rt.set_device(0)"
验证结果
pip3 install attrs cython numpy decorator sympy cffi pyyaml pathlib2 psutil protobuf==3.20.0 scipy requests absl-py --user
pip3 install protobuf==3.20.0
如果安装过程中遇到问题:
详细参考资料请查看 reference 目录,包含:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/external-gitcode-ascend-skills:external-gitcode-ascend-cann-operator-env-configfrom external-gitcode-ascend-skills
npx claudepluginhub ascend-ai-coding/awesome-ascend-skills --plugin external-gitcode-ascend-skills91 skills in this plugin
/external-gitcode-ascend-analyse-coverage分析测试覆盖率盲区,生成覆盖率分析报告/external-gitcode-ascend-arxiv-recommendation-npu自动化推荐系统论文发现流水线。抓取 arxiv 推荐论文,检测源码,生成待迁移任务清单,由 npu-model-migration skill 完成 NPU 适配。/external-gitcode-ascend-ascendc-operator-code-gen根据设计文档生成 AscendC 算子完整代码实现并完成框架适配。TRIGGER when: 设计文档已完成,需要生成 op_host/op_kernel 代码、注册到 PyTorch 框架、编译测试。关键词:代码生成、op_host、op_kernel、tiling、kernel、框架适配、算子注册。Other plugins' skills for the same job