Skip to content
Back to skills

Ascendc Env Check

ASecurity

Ascend C 算子开发环境检查技能。用于:(1) 通过 npu-smi 查询 NPU 设备信息(设备列表、状态、资源使用),(2) 检查 CANN 环境配置(CANN Toolkit、Ops、自定义算子包),(3) 验证开发依赖是否完整,(4) 运行时检测当前设备 NPU 架构。触发关键词:环境检查、NPU设备、npu-smi、CANN安装、设备查询、资源监控、检查CANN环境变量、NPU架构、npu arch。

  • 21 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added November 7, 2026
toolspythonbashapi

Works with

  • api

Security analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned November 24, 2026

npx -y skills add hicann/cannbot-skills --skill ascendc-env-check --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ascendc Env Check?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ascendc Env Check
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hicann-ascendc-env-check/badge)](https://www.skillsdirectory.com/skills/hicann-ascendc-env-check)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ascendc-env-check
description: Ascend C 算子开发环境检查技能。用于:(1) 通过 npu-smi 查询 NPU 设备信息(设备列表、状态、资源使用),(2) 检查 CANN 环境配置(CANN Toolkit、Ops、自定义算子包),(3) 验证开发依赖是否完整,(4) 运行时检测当前设备 NPU 架构。触发关键词:环境检查、NPU设备、npu-smi、CANN安装、设备查询、资源监控、检查CANN环境变量、NPU架构、npu arch。
---

# Ascend C 环境检查

快速检查开发环境配置和 NPU 设备状态。

## 工作流程

```
环境检查
    │
    ├─ NPU 设备检查
    │   └─ npu-smi info -m / scripts/npu_info.sh
    │
    ├─ CANN 环境检查
    │   └─ scripts/check_env.sh
    │
    └─ NPU 架构检测
        └─ scripts/get_npu_arch.py
```

## NPU 设备检查

### 快速命令

```bash
# 查看设备详细信息(包含设备列表)
npu-smi info

# 监控设备资源
npu-smi info -t usages -i <device_id>
```

### 脚本工具

```bash
# 综合 NPU 信息(推荐)
bash scripts/npu_info.sh
```

详细命令参数见 [npu_commands.md](references/npu_commands.md),npu-smi 不可用时的回退方案见 [asys_commands.md](references/asys_commands.md)

## CANN 环境检查

```bash
# 完整环境检查(推荐)
bash scripts/check_env.sh
```

### 检查项

| 检查项 | 说明 | 必需 |
|--------|------|------|
| ASCEND_HOME_PATH | CANN Toolkit 路径 | 是 |
| CANN 版本 | 检测版本号及运行时依赖基线 | 建议确认 |
| ASCEND_OPP_PATH | CANN Ops 路径 | 运行时必需 |
| 自定义算子包 | op_api 库 | 运行自定义算子必需 |
| CANN 工具 | msprof/cannsim | 可选 |

> ⚠️ **注意**:官方环境变量为 `ASCEND_HOME_PATH`,不是 `ASCEND_HOME`。部分旧文档或示例代码可能使用 `ASCEND_HOME`,这是错误用法。

详细环境配置见 [env_config_guide.md](references/env_config_guide.md),版本配套关系见其中「CANN 版本兼容性」章节

## NPU 架构检测

**前置条件**:先 source CANN 安装目录下的 `set_env.sh`(asys 与 DSMI 库依赖其 PATH / LD_LIBRARY_PATH)。

**重要**:npu-smi 的 Chip Name 作为 short-soc-version **不可信**(A3 机型误报 `Ascend910`,issue #587),禁止用于芯片型号识别。

```bash
# 人读报告(含用途注释与证据链)
python3 scripts/get_npu_arch.py

# 仅输出裸 NpuArch 数值(如 3510)
python3 scripts/get_npu_arch.py --raw

# 机器可读 JSON(键名:full_soc / full_soc_source / npu_arch / npu_arch_source / short_soc / ccec_aiv_version / variant_dir / ini_path / npu_count / warnings)
python3 scripts/get_npu_arch.py --json
```

**获取链**:

| 获取项 | 优先来源 | 备选来源 |
|---|---|---|
| full-soc-version(如 `Ascend950PR_9579`) | asys `info -r=hardware` Chip Info | DSMI `dsmi_get_chip_info` |
| NpuArch(如 `3510`) | asys Arch Info | ini 文件(full-soc-version 精确匹配) |
| short-soc-version / CCE_AIV_version / variant_dir | ini 文件 | — |

- short-soc-version(如 `Ascend950`)用于算子原型定义文件 `xxx算子_def.cpp` 的 `AddConfig()` 第一个参数(如 `this->AICore().AddConfig("ascend950", aicConfig)`)
- variant_dir(如 `dav_c310`)决定读CANN安装目录下源码时只看 `**/dav_c310/` 下的文件
- ini 匹配按 `SoC_version=` 字段精确匹配,禁止文件名/前缀模糊匹配

**依赖**:Ascend driver 和 CANN toolkit。

## 诊断脚本

| 脚本 | 用途 |
|------|------|
| `scripts/npu_info.sh` | NPU 设备信息综合查询 |
| `scripts/check_env.sh` | CANN 环境配置检查 |
| `scripts/get_npu_arch.py` | 运行时检测当前设备 NPU 架构 |

也可直接调用 `_npu_info.py` Python 脚本获取结构化数据,支持 `--json`(完整 JSON 输出)、`--list`(设备 ID 列表)、`--health`(健康状态)等参数。

## 常见问题

- **NPU 不可见**:先执行 `npu-smi info -m` 检查设备映射表,再排查驱动是否安装正确
- **算子运行失败**:**优先**运行 `check_env.sh` 检查环境配置是否完整,并检查关键环境变量(`ASCEND_HOME_PATH`、`ASCEND_OPP_PATH`)是否已正确设置
- **确认是否有进程占用 NPU**:使用 `npu-smi info -t usages -i <device_id>` 查看运行中的进程;注意空闲设备仍会有少量 HBM 被驱动占用(正常现象),不应误判为设备被占用

详细排查见 [troubleshooting.md](references/troubleshooting.md)

Files in this skill

  • SKILL.md5.2 KB
  • evals/evals.json10.6 KB
  • references/asys_commands.md1.4 KB
  • references/env_config_guide.md3.5 KB
  • references/kirin_platform_guide.md857 B
  • references/npu_commands.md3.2 KB
  • references/troubleshooting.md3.9 KB
  • scripts/_npu_info.py26.3 KB
  • scripts/check_env.sh10.1 KB
  • scripts/get_npu_arch.py17.5 KB
  • scripts/npu_info.sh8.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.