本项目将 timm/wide_resnet50_2.tv2_in1k 图片分类模型适配到单卡昇腾 NPU (Ascend910B)。
timm.create_model(pretrained=False) 创建模型,通过 ModelScope snapshot_download 下载本地权重并加载,在 NPU 上执行推理。model.safetensors)| 项目 | 版本/信息 |
|---|---|
| NPU | Ascend910B |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 适配 CANN 8.5.1 |
| timm | latest |
环境详情见 logs/env_check.log。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.005863 |
| mean_abs_error | 0.000853 |
| relative_error | 0.1285% |
| cosine_similarity | 0.999999 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| 运行次数 | 10 |
| 平均耗时 | 0.0083 s |
| 最小耗时 | 0.0078 s |
| 最大耗时 | 0.0089 s |
| P50 | 0.0082 s |
| P90 | 0.0089 s |
| P95 | 0.0089 s |
| 吞吐量 | 120.96 images/sec |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/env_check.log — NPU 环境信息logs/inference.log — 推理结果logs/accuracy.log — CPU-NPU 精度一致性logs/benchmark.log — 性能基准测试torch_npu 日志中的 path string is NULL 和权限警告为环境已知提示,不影响推理正确性。#NPU #Ascend #Ascend910 #timm #image-classification