CANN/cann-recipes-embodied-intelligence ACT训练样例
ACT 在昇腾 Atlas A2 上的训练样例【免费下载链接】cann-recipes-embodied-intelligence本项目针对具身智能业务中的典型模型、加速算法提供基于CANN平台的优化样例项目地址: https://gitcode.com/cann/cann-recipes-embodied-intelligence本目录提供 ACT 训练样例完成 ALOHAtransfer_cube任务的模型训练以及方便拓展到其他任务上。当前样例遵循以下原则cann-recipes仓库中仅保存训练样例目录、配置、脚本、文档和补丁lerobot作为外部依赖仓单独 clonesetup.sh固定lerobotcommit id并对已验证的通用 Ascend 训练补丁执行git apply1. 适用场景硬件昇腾 Atlas A2CANN8.3.0 及以上任务AlohaTransferCube-v0数据集lerobot/aloha_sim_transfer_cube_human外部训练框架huggingface/lerobot2. 外部依赖与固定版本本样例不内嵌lerobot源码默认使用如下 commit58f70b6bd370864139a3795ac3497a9eae8c42d53. 目录说明manipulation/act/train/ ├── README.md ├── doc/ │ └── README.md └── src/ ├── configs/ │ ├── act_aloha.yaml │ └── act_aloha_smoke.yaml ├── patches/ │ └── lerobot_ascend_train_common.patch └── scripts/ ├── run_eval.sh ├── run_train.sh └── setup.sh4. 环境准备4.1 clone 代码git clone https://gitcode.com/cann/cann-recipes-embodied-intelligence.git cd cann-recipes-embodied-intelligence4.2 准备lerobot执行chmod x manipulation/act/train/src/scripts/setup.sh ./manipulation/act/train/src/scripts/setup.sh该脚本会在cann-recipes同级目录下准备lerobot代码仓checkout 到固定 commit58f70b6bd370864139a3795ac3497a9eae8c42d5应用当前已验证的 Ascend 训练补丁包含 ACT 使用torchcodec所需的视频解码容忍度修正安装 ACT 所需的 LeRobot 通用 Python 依赖与gym-aloha默认复用当前已激活环境中的torch/torch_npu如需在新环境中执行可通过参数创建 conda 环境并通过本地 wheel 注入平台相关的torch/torchvision/torch_npu。常见用法# 查看脚本帮助 ./manipulation/act/train/src/scripts/setup.sh --help # 用当前已准备好的 Ascend 环境 ./manipulation/act/train/src/scripts/setup.sh # 创建新 conda 环境并从本地 wheel 安装平台栈 ./manipulation/act/train/src/scripts/setup.sh \ --create-conda \ --env-name lerobot-act \ --python-version 3.10 \ --torch-wheel /path/to/torch.whl \ --torchvision-wheel /path/to/torchvision.whl \ --torch-npu-wheel /path/to/torch_npu.whl说明之所以不在脚本中硬编码torch_npu下载链接是因为有效的 wheel 组合依赖于宿主机架构、CANN 版本和 Ascend 软件栈这部分平台依赖建议由已有训练环境复用或由使用者自行提供本地 wheel。如已提前确认平台栈可用也可以追加--skip-torch-check跳过末尾导入校验。4.3 数据集路径当前配置默认使用工作区相对路径../dataset/lerobot/aloha_sim_transfer_cube_human如需调整请修改src/configs/act_aloha.yamlsrc/configs/act_aloha_smoke.yaml这些相对路径默认相对于lerobot根目录解析推荐工作区布局如下workspace/ ├── cann-recipes-embodied-intelligence/ ├── lerobot/ ├── dataset/ │ └── lerobot/ │ └── aloha_sim_transfer_cube_human/ └── ckpt/要求root必须直接指向包含data/、meta/的数据集根目录。4.4 ResNet18 权重缓存ACT 默认使用pretrained_backbone_weights: ResNet18_Weights.IMAGENET1K_V1首次训练或评测时PyTorch 可能会尝试下载resnet18-f37072fd.pth。在无外网环境中建议提前将该文件放到当前用户的 PyTorch 权重缓存目录例如~/.cache/torch/hub/checkpoints/resnet18-f37072fd.pth可在有外网的机器上从 PyTorch 官方地址下载wget -O resnet18-f37072fd.pth https://download.pytorch.org/models/resnet18-f37072fd.pth也可以使用curl -L https://download.pytorch.org/models/resnet18-f37072fd.pth -o resnet18-f37072fd.pth下载后将文件拷贝到目标机器的 PyTorch 权重缓存目录mkdir -p ~/.cache/torch/hub/checkpoints cp resnet18-f37072fd.pth ~/.cache/torch/hub/checkpoints/如果设置了TORCH_HOME则实际缓存目录为$TORCH_HOME/hub/checkpoints/。可以通过以下命令确认当前环境的缓存根目录python -c import torch; print(torch.hub.get_dir())如果服务器无法联网又没有提前缓存ACT 会在模型构建阶段失败。5. 训练配置5.1 smoke 配置配置文件src/configs/act_aloha_smoke.yaml作用快速验证环境、数据、依赖和多卡训练链路关键参数steps: 20wandb.enable: false启动./manipulation/act/train/src/scripts/run_train.sh act_aloha_smoke --port 295105.2 长训配置配置文件src/configs/act_aloha.yaml关键参数dataset.video_backend: torchcodecsteps: 100000batch_size: 8num_workers: 4wandb.enable: true启动./manipulation/act/train/src/scripts/run_train.sh act_aloha --port 295106. 评测说明run_eval.sh只是对lerobot-eval的轻量封装参数直接透传。在线评测建议将 MuJoCo 仿真与渲染放在 CPU 侧执行policy 推理继续使用 NPU原因见 doc/README.md。示例export MUJOCO_GLosmesa ./manipulation/act/train/src/scripts/run_eval.sh \ --policy.path/path/to/pretrained_model \ --policy.devicenpu \ --env.typealoha \ --env.taskAlohaTransferCube-v0 \ --eval.n_episodes100 \ --eval.batch_size20 \ --output_dir/path/to/eval_out说明MUJOCO_GLosmesa表示 MuJoCo 使用 CPU 软件渲染--policy.devicenpu表示模型前向推理继续放在 NPU这种方式对应“仿真在 CPU推理在 NPU”。7. 已验证结果摘要当前样例已切换为默认使用torchcodec解码视频。 当前已验证的一组参考结果训练任务ACT onlerobot/aloha_sim_transfer_cube_human任务环境AlohaTransferCube-v0数据规模50episodes20000frames训练硬件昇腾 Atlas A28卡训练步数100000训练 batch 配置batch_size: 8全局 batch size64统计区间WBtrain/steps 5000 ~ 20000评测方式5 x 100episodes评测总成功率68.0%当前已完成一组100 step的快速吞吐验证可作为当前配置下的参考最佳结果场景统计区间mean_updt_smean_data_send-to-end samples/s8 cards x bs64 x torchcodecstep 10~1000.31910.3544760.24更详细的环境、日志、checkpoint 路径和评测说明见doc/README.md说明默认配置中的video_backend已显式设置为torchcodec8. WB 记录占位9. 常用命令查看训练日志cd ../lerobot tail -f ../ckpt/logs/train_act_aloha_*.logresume 训练./manipulation/act/train/src/scripts/run_train.sh act_aloha --resume --port 2951010. 相关说明本样例目录不包含lerobot源码若后续需要扩展到其他 ALOHA 数据集可新增新的 YAML。样例参考 https://gitcode.com/cann/cann-recipes-embodied-intelligence/blob/master/manipulation/pi05/train/README.md【免费下载链接】cann-recipes-embodied-intelligence本项目针对具身智能业务中的典型模型、加速算法提供基于CANN平台的优化样例项目地址: https://gitcode.com/cann/cann-recipes-embodied-intelligence创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考