关于 ascend-model-migration
面向 Ascend NPU 的模型迁移与训练技能套件,供需要将开源模型适配到 Ascend 环境的开发者使用。它串联 SSH 连接、环境依赖安装、代码迁移和训练流程,并列出 BEVFormer 支持。
主要功能
- 01串联远程连接、环境准备、迁移与训练
- 02安装 MMLab 相关依赖
- 03克隆模型仓库并应用 NPU 适配补丁
- 04支持 BEVFormer 训练流程
- 05提供环境检查与常见错误处理指引
适用场景
- 01在 Ascend NPU 上准备模型训练环境
- 02迁移开源模型并应用 NPU 补丁
- 03启动并监控 BEVFormer 训练
- 04排查 SSH、NPU 设备或补丁问题
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ ascend/ agent-skills --skill ascend-model-migration安装后在 Claude Code 中输入/ascend-model-migration确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
README.mdascend-mmlab-install-suite/README.mdascend-mmlab-install-suite/script/verify_mmlab_imports.pyssh-connection/config.example.yamlconfig.yamlREADME.mdssh-connection/_lib/_python.shssh-config.pyssh-connection/connect/scripts/ssh-download.shssh-exec.shssh-job.shssh-test.shssh-upload.shssh-connection/deploy/scripts/ssh-deploy.shssh-connection/long-task/scripts/checkpoint.shssh-connection/tunnel/scripts/ssh-tunnel.sh详细介绍
Ascend 模型迁移套件
适用于 Ascend NPU 环境的完整模型迁移与训练套件。该套件提供从 SSH 连接到模型训练的端到端工作流。
适用场景
- 用户希望将开源模型迁移到 Ascend NPU
- 用户需要在 Ascend NPU 上配置训练环境
- 用户希望在 Ascend NPU 上训练模型(BEVFormer 等)
- 用户询问 Ascend 平台上的模型部署
套件结构
ascend-model-migration/
├── SKILL.md # Main skill (this file)
├── ssh-connection/ # SSH connection skill (from ssh-dev-suite)
│ └── SKILL.md
├── model-migration/ # Model migration skill
│ └── SKILL.md
└── model-training/ # Model training skill
└── SKILL.md
# External Dependencies (in AgentSkills/skills/)
└── ascend-mmlab-install-suite/ # MMLab environment setup
└── SKILL.md
工作流概览
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ ssh-connection │ ──► │ mmlab-install │ ──► │ model-migration │ ──► │ model-training │
│ │ │ -suite │ │ │ │ │
│ Connect to │ │ Install mmcv, │ │ Clone repo, │ │ Execute │
│ Ascend server │ │ mmdet, mmdet3d │ │ apply patches │ │ training script│
└─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘
完整工作流
阶段 0:准备 DrivingSDK
DrivingSDK 仓库地址:https://gitcode.com/Ascend/DrivingSDK
开始任何工作前,请确认 DrivingSDK 已克隆到工作目录:
cd <working_directory>
git clone https://gitcode.com/Ascend/DrivingSDK
重要:DrivingSDK 包含所有必要的补丁文件和训练脚本,无需向用户询问补丁位置。
阶段 1:收集环境信息
向用户询问以下信息:
1. Server IP address (e.g., 192.168.13.151)
2. SSH username (e.g., root)
3. Docker container name (if applicable, e.g., qianqian_0312)
4. Conda environment name (e.g., qianqian_2)
5. Working directory path (e.g., /home/zqq/0312_trae_new)
使用 ssh-connection 技能(本套件)建立连接。
阶段 2:环境配置
使用 AgentSkills/skills/ascend-mmlab-install-suite/ 安装依赖项:
- 验证基础环境(torch、torch_npu、CANN)
- 安装 MMLab 依赖项:
- mmcv-full(含 NPU 算子)
- mmdetection
- mmsegmentation
- mmdetection3d
- detectron2
阶段 3:模型迁移
使用 model-migration 技能(本套件)准备模型代码:
- 克隆开源仓库
- 应用 NPU 适配补丁
- 配置数据集和权重链接
阶段 4:模型训练
使用 model-training 技能(本套件)启动训练:
- 选择训练模式(性能/精度)
- 执行训练脚本
- 监控训练进度
支持的模型
| 模型 | 状态 | DrivingSDK 路径 |
|---|---|---|
| BEVFormer | ✅ 已支持 | model_examples/BEVFormer |
| 更多模型 | 🔄 即将推出 | - |
快速入门示例
User: "I want to train BEVFormer on Ascend NPU"
Agent workflow:
1. [ssh-connection] Ask for server info → Connect
2. [ascend-mmlab-install-suite] Check environment → Install MMLab deps
3. [model-migration] Clone BEVFormer → Apply patch → Link data
4. [model-training] Launch training → Monitor progress
核心原则
NPU 兼容性检查
安装后,验证 NPU 兼容性:
python -c "import site; print([p for p in site.getsitepackages() if 'cuda' in p.lower()])"
在 NPU 环境中应返回空列表 []。
网络策略
| 情况 | 策略 |
|---|---|
| 服务器可以访问 GitHub | 直接在服务器上执行 git clone |
| 服务器网络超时 | 配置代理,或在本地克隆后通过 scp 传到服务器 |
| 有可用代理 | 配置代理:export http_proxy=http://proxy:port |
重要:克隆所有 GitHub 仓库时都应使用 GitHub 官方链接,不要使用镜像站点。如果网络超时,请优先配置代理。
错误处理
每个子技能都会处理自身错误并提供恢复建议。常见问题:
- SSH 连接失败:检查 IP、用户名、密码/密钥
- 未找到 NPU 设备:检查环境变量
- CUDA 路径冲突:重新安装并启用 NPU 支持
- 补丁应用失败:检查代码版本
环境变量参考
常见的 Ascend NPU 环境变量:
export ASCEND_SLOG_PRINT_TO_STDOUT=0
export ASCEND_GLOBAL_LOG_LEVEL=3
export TASK_QUEUE_ENABLE=2
export COMBINED_ENABLE=1
export HCCL_WHITELIST_DISABLE=1
export HCCL_CONNECT_TIMEOUT=1200
注意:在特定环境中可能需要设置 ASCEND_RT_VISIBLE_DEVICES。
参考文件
- SSH 连接:
ssh-connection/SKILL.md(本套件) - MMLab 安装套件:
AgentSkills/skills/ascend-mmlab-install-suite/SKILL.md - DrivingSDK 路径:
DrivingSDK/model_examples/ - 模型迁移:
model-migration/SKILL.md(本套件) - 模型训练:
model-training/SKILL.md(本套件)
评论
支持 Markdown