Guides users through setting up HuggingFace Diffusers on Huawei Ascend NPU, covering CANN version detection, PyTorch + torch_npu installation, Diffusers library setup, and environment validation.
Ships in diffusers-ascend-env-setup. 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.
本 Skill 指导用户在华为昇腾 NPU 上配置 HuggingFace Diffusers 开发环境。
4 步完成环境搭建:
# 1. 激活 CANN 环境(自动检测版本)
if [ -d "/usr/local/Ascend/cann" ]; then
source /usr/local/Ascend/cann/set_env.sh
else
source /usr/local/Ascend/ascend-toolkit/set_env.sh
fi
# 2. 安装 PyTorch + torch_npu(版本自动匹配)
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install torch-npu # 自动匹配已安装的 PyTorch 版本
# 3. 安装 Diffusers
pip install diffusers["torch"] transformers
# 4. 验证环境
python scripts/validate_environment.py
| 步骤 | 详细指南 |
|---|---|
| CANN 验证 | references/cann-versions.md |
| PyTorch + torch_npu | references/installation.md |
| Diffusers 安装 | references/installation.md |
| 组件 | 版本 | 说明 |
|---|---|---|
| CANN | 8.0.RC1+ | NPU 支持必需 |
| PyTorch | 2.1.0 - 2.8.0 | 含 torch_npu 扩展 |
| Diffusers | 0.28.0+ | 支持 SDXL、SD3、Flux |
torch_npu 版本匹配:
pip install torch-npu示例(CANN 8.3.RC1):
| PyTorch | torch_npu | Python |
|---|---|---|
| 2.8.0 | 2.8.0 | 3.9 - 3.11 |
| 2.7.1 | 2.7.1 | 3.9 - 3.11 |
| 2.6.0 | 2.6.0.post3 | 3.9 - 3.11 |
运行验证脚本:
python scripts/validate_environment.py
检查项:
| 检查项 | 说明 |
|---|---|
| CANN 安装 | 目录存在且环境变量已设置 |
| PyTorch | import 成功,版本匹配 |
| torch_npu | import 成功,NPU 可见 |
| Diffusers | import 成功 |
| numpy | 版本 < 2.0 |
What SKILL.md sets; muted values are Claude Code's defaults
/diffusers-ascend-env-setup:diffusers-ascend-env-setupfrom diffusers-ascend-env-setup
npx claudepluginhub ascend-ai-coding/awesome-ascend-skills --plugin diffusers-ascend-env-setupOther plugins' skills for the same job