Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.6 KB

File metadata and controls

45 lines (31 loc) · 1.6 KB

快速入手

调用 Driving SDK 高性能 API

import torch, torch_npu
from mx_driving import scatter_max
updates = torch.tensor([[2, 0, 1, 3, 1, 0, 0, 4], [0, 2, 1, 3, 0, 3, 4, 2], [1, 2, 3, 4, 4, 3, 2, 1]], dtype=torch.float32).npu()
indices = torch.tensor([0, 2, 0], dtype=torch.int32).npu()
out = updates.new_zeros((3, 8))
out, argmax = scatter_max(updates, indices, out)

使用 Driving SDK 快速迁移自动驾驶模型

为方便用户快速在NPU上跑通基于GPU生态开发的模型,Driving SDK 提供了一键迁移能力,用户仅需添加两行代码即可。

1. 定位模型训练脚本入口

找到模型的训练脚本,通常命名为train.py,定位到它的入口函数,通常为:

if __name__ == '__main__':
    main()

2. 应用一键patcher

from mx_driving.patcher import default_patcher_builder
#......
if __name__ == '__main__':
    with default_patcher_builder.build() as patcher:
      main()

若模型训练报错,可进一步参考模型FAQ进行排查。若希望进一步了解一键patcher特性,可查阅一键Patcher文档

3. 进一步优化模型性能

若NPU上训练性能跟基线差距较大,可参考模型迁移优化指导负载均衡优化进一步优化hostbound、快慢卡等性能瓶颈。

4. 导出离线模型

Driving SDK 支持单算子onnx导出,并提供了示例,用户若有诉求需自行参考训推一体示例开发。