本文档记录 RADIO-L 在昇腾 NPU 环境的适配与验证结果。
模型信息:
[1, 3, 768, 768]summary (全局特征) + spatial_features (空间特征)相关地址:
| 组件 | 版本 |
|---|---|
torch | 2.10.0 |
torch_npu | 2.10.0 |
transformers | 5.8.1 |
timm | - |
einops | - |
1 逻辑卡/data/xxy/RADIO-Lradio-lconda create -n radio-l python=3.11 -y
conda activate radio-lpip install torch==2.10.0 torchvision --index-url https://download.pytorch.org/whl/cpu
pip install torch_npu transformers pillow timm einops -i https://repo.huaweicloud.com/repository/pypi/simplepython -c "import torch; print('NPU available:', torch.npu.is_available())"RADIO 模型通过 HuggingFace AutoModel 加载,需要 trust_remote_code=True,主要适配工作:
model.to("npu:0") 将模型权重迁移到 NPUx.to("npu:0")torch.npu.synchronize() 确保计算完成# 使用随机张量推理
python inference.py
# 使用图片推理
python inference.py --image /path/to/image.jpg
# 指定设备
python inference.py --device cpu
python inference.py --device npu:0python eval.py评测结果将输出到终端并保存到 log.txt。
由于 RADIO-L 模型较大(320M 参数),CPU 推理时间过长,评测时使用 NPU 单卡运行验证。
| 输出 | 状态 |
|---|---|
summary | shape: [1, 3072] |
spatial_features | shape: [1, 2304, 1024] |
| 全局 | ✅ PASS |
| 指标 | NPU |
|---|---|
| 平均推理耗时 | 43.81 ms |
| 吞吐量 | 22.82 steps/s |
RADIO-L-ascend/
├── inference.py # 推理脚本
├── eval.py # 精度与性能评测脚本
├── log.txt # 评测日志
└── README.md # 本文档[1, 3, 768, 768](与原版一致)radio-ltrust_remote_code=True 加载模型x 而非 pixel_values