Validates and configures Ascend NPU triton operator dev environment: checks CANN, Python, torch/torch_npu, triton-ascend dependencies and PATH. Use when setting up or verifying the environment for triton operator development on Ascend.
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; scripts run unread.
必须按顺序执行环境检查,每个步骤依赖前一步的成功。
配套版本可能更新,必须先获取官方最新文档。
MANDATORY - READ ENTIRE PAGE:访问并完整阅读官方在线文档 https://triton-ascend.readthedocs.io/zh-cn/latest/quick_start.html 和 https://triton-ascend.readthedocs.io/zh-cn/latest/installation_guide.html,获取最新的:
以文档中的版本要求为准,更新后续步骤中的版本号。
以下版本对应关系仅供参考(截止 2026-03-26),以在线文档为准:
| Triton-Ascend 版本 | CANN 版本 | 发布日期 |
|---|---|---|
| 3.2.0 | 8.5.0(推荐) | 2026/01/16 |
| 3.2.0rc4 | 8.3.RC2 | 2025/11/20 |
torch_npu 版本(仅供参考):2.7.1
⚠️ 如果在线文档中的版本与上表不一致,必须以在线文档为准。
必须最先检查 CANN 环境
npu-smi info,检查是否成功加载驱动which bisheng,检查是否成功加载CANN环境获取到npuir编译器,应该输出路径source /usr/local/Ascend/cann/set_env.shsource /usr/local/Ascend/ascend-toolkit/set_env.sh如果遇到python问题,最优先使用miniconda创建环境解决
which python3export PATH="/usr/bin:$PATH"python3 --version,以官方 quick_start.md 文档中的要求为准conda init bash检查是否有conda环境,有则跳转第5步,如果没有则执行第2步安装uname -m确认当前系统架构
如果系统架构为aarch64,执行:wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh
如果系统架构为x86_64,执行:wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.shbash Miniconda3-latest-Linux-x86_64.sh或bash Miniconda3-latest-Linux-aarch64.sh,按照提示安装后激活miniconda环境conda init bashconda create -n triton python=<官方要求版本>conda activate triton必须保证前面的步骤都成功
pip list | grep "torch"pip install torch==<官方要求版本>ERROR: No matching distribution found for torch==2.7.1+cpu,尝试:
pip install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu
pip install torch_npu==<官方要求版本>python3 -c "import torch; print(torch.__version__)"python3 -c "import torch; a = torch.randn(2, 3); print(a)",应该输出类似结果:tensor([[2.86, 1.0406, 1.5811], [0.8329, 1.0024, 1.3639]])pip list | grep "triton"pip uninstall tritonpip install triton-ascend用于确认当前终端环境可以正常执行triton算子。
MANDATORY - READ ENTIRE FILE:在执行验证前,必须完整阅读 scripts/01-vector-add.py。
执行验证:
python3 <skill-dir>/scripts/01-vector-add.py
执行该算子样例后,如出现类似结果则表明其计算符合预期,difference为0.0则视为验证通过:
tensor([0.8329, 1.0024, 1.3639, ..., 1.0796, 1.0406, 1.5811], device='npu:0')
tensor([0.8329, 1.0024, 1.3639, ..., 1.0796, 1.0406, 1.5811], device='npu:0')
The maximum difference between torch and triton is 0.0
| 现象 | 动作 |
|---|---|
| torch 安装失败:No matching distribution found for torch==2.7.1+cpu | 尝试从 PyTorch 官方源安装:pip install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu |
| 同时安装了原生 triton 和 triton-ascend | 先卸载原生 triton:pip uninstall triton,再重新安装 triton-ascend |
| 找不到 C++ compiler | 安装编译器:apt-get install g++ |
| 需要从源码编译时缺少依赖 | 安装系统库:sudo apt install zlib1g-dev clang-15 lld-15(推荐 clang >= 15, lld >= 15) |
| 已按上表重试仍失败 | 保留完整终端报错与已执行的命令序列,便于本地或后续排查 |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ascend, triton-operator, npu, cann, environment-setup, triton-ascend
/external-gitcode-ascend-skills:external-gitcode-ascend-triton-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