external-gitcode-ascend-cann-operator-env-config

Provides guidance for installing CANN and configuring the Ascend environment. Invoked when a user needs to install CANN, configure the Ascend environment, or troubleshoot installation issues.

Last repository push
GitHub Stars
187
Forks
67
Issues / PRs
15

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "external-gitcode-ascend-cann-operator-env-config" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-a4dfd51ca16246e72a52363dcf264022a5f361a4a57421e97e60346ab3d1379b. Verify the upstream source and version against https://github.com/ascend-ai-coding/awesome-ascend-skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Provides guidance for installing CANN and configuring the Ascend environment. Invoked when a user needs to install CANN, configure the Ascend environment, or troubleshoot installation issues.

0 Downloads

Introduction source: third_party · ascend-ai-coding · 0.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: external-gitcode-ascend-cann-operator-env-config
description: 提供昇腾NPU的CANN安装指导。当用户需要安装CANN、配置昇腾环境或解决安装问题时调用。
original-name: cann-operator-env-config
synced-from: https://gitcode.com/Ascend/agent-skills
synced-date: '2026-05-26'
synced-commit: 1f7666e7768a0ceb21bb1d40ce4b5179fcb6f1d6
license: UNKNOWN

CANN开发环境配置

此技能为在昇腾NPU平台上安装CANN(神经网络计算架构)提供全面指导。

调用时机

在以下情况下调用此技能:

  • 用户询问CANN安装
  • 用户需要帮助设置昇腾开发环境
  • 用户遇到CANN安装问题
  • 用户想了解CANN安装方法

安装步骤

第1步:检查驱动是否安装

硬件要求

  • 已安装昇腾NPU设备
  • 设备状态正常

驱动检查命令

npu-smi info

检查结果

  • 如果显示NPU设备信息,说明驱动已安装
  • 记录驱动版本用于后续CANN版本兼容性检查
  • 如果提示"command not found",需要先安装昇腾驱动

第2步:检查CANN安装依赖

检查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步:安装CANN

方法一:离线安装

步骤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方式)

注意: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

方法三:在线安装(yum方式 - CentOS/RHEL)

步骤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

第4步:环境变量配置

临时设置(仅当前终端生效)

source /usr/local/Ascend/ascend-toolkit/set_env.sh

永久设置(写入Shell配置文件)

echo "source /usr/local/Ascend/ascend-toolkit/set_env.sh" >> ~/.bashrc

第5步:安装验证

使用Python验证ACL接口

python3 -c "import acl;acl.init();acl.rt.set_device(0)"

验证结果

  • 如果执行成功,说明CANN Python接口正常工作
  • 如果执行失败,检查环境变量是否配置正确

第6步:安装运行时依赖

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

注意事项

  1. 版本兼容性:确保CANN版本与驱动版本匹配
  2. 安装顺序:必须先安装Toolkit,再安装ops
  3. 环境变量:安装后必须设置环境变量
  4. 权限问题:某些操作可能需要root权限
  5. 依赖包:确保所有必要的依赖包已安装

故障排查

如果安装过程中遇到问题:

  • 检查驱动版本是否与CANN版本兼容
  • 检查依赖包是否安装完整
  • 查看安装日志获取详细错误信息
  • 参考昇腾社区文档或寻求技术支持

参考资料

详细参考资料请查看 reference 目录,包含:

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供昇腾NPU CANN的完整安装流程,覆盖离线、conda、yum三种主流方式
  • 包含详细的依赖检查、环境变量配置与安装验证闭环
Trigger Precision85/100

Areas to improve

  • description写错位置 Reported severity: Minor

    顶层frontmatter已定义description,但skill_body内部重复定义

    Recommendation: 移除skill_body内部的description定义,保持frontmatter唯一性

Highlights

  • 触发词精准聚焦于'CANN安装'、'昇腾环境配置'等核心场景
Structure and Standards90/100

Highlights

  • 分6个清晰步骤组织流程,每步含具体命令与验证逻辑
  • frontmatter完整,含同步来源与许可信息
Execution Reliability80/100

Areas to improve

  • 缺少When to Use独立章节 Reported severity: Minor

    文档使用'调用时机'等效内容但未按标准命名

    Recommendation: 建议将'调用时机'章节标题改为'When to Use'以符合规范

  • 部分命令缺少权限确认提示 Reported severity: Minor

    yum install等命令需root权限但未显式提示用户确认

    Recommendation: 在涉及系统级操作的步骤前添加权限确认提示

Evidence Verifiability (mean of the first four)83/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • gitcode.com
  • repo.huaweicloud.com
  • repo.oepkgs.net

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.