首先的步骤,安装模型转换工具
下载Verisilicon_Tool_Acuity_Toolkit和Verisilicon_Tool_VivanteIDE,按照文档安装配置

Vivante_IDE居然有Windows版本的,还亏我费劲装了个Ubuntu虚拟机


好像需要License?


去申请了一个license,马上就到货了


先准备下模型,去darknet上下载预先训练好了的
https://pjreddie.com/darknet/


配置一下环境变量,写了个脚本干这个

export ACTU_BASE=$(ls | grep acu*) && \
export ACTU_IDE_BASE=$(ls | grep *IDE*) && \
echo -e "ACUITY_TOOLS_METHOD='$PWD/$ACTU_BASE'\nexport ACUITY_PATH='$PWD/$ACTU_BASE/bin/'\nexport VIV_SDK='$PWD/$ACTU_IDE_BASE/cmdtools'\nexport PATH=$PATH:$PWD/$ACTU_BASE/bin/:$PWD/$ACTU_IDE_BASE/ide/\nexport pegasus=$PWD/$ACTU_BASE/bin/pegasus\nalias pegasus=$PWD/$ACTU_BASE/bin/pegasus" >> ~/.bashrc && \
source ~/.bashrc

按照文档说明导入模型,转换模型,量化,测试,导出小端模型


报错了

Create Neural Network: 208ms or 208405us
E [../vnn_pre_process.c:_decode_jpeg:279]CHECK PTR 279
E [../vnn_pre_process.c:_get_jpeg_data:622]CHECK PTR 622
E [../vnn_pre_process.c:_handle_multiple_inputs:762]CHECK PTR 762
E [../vnn_pre_process.c:vnn_PreProcessYolov3prj:910]CHECK STATUS(-1:A generic error code, used when no other describes the error.)
E [../main.c:main:241]CHECK STATUS(-1:A generic error code, used when no other describes the error.)

顺着调用查了一下

bmpFile = fopen( name, "rb" );

这里报错了

打印一下看看,好像很正常

    printf("%s", name);bmpFile = fopen( name, "rb" );TEST_CHECK_PTR(bmpFile, final);

把TEST_CHECK注释了看看

//TEST_CHECK_PTR(bmpFile, final);

试试用这个记录下运行时间

#define BILLION                                 1000000000
static uint64_t get_perf_count()
{
#if defined(__linux__) || defined(__ANDROID__) || defined(__QNX__) || defined(__CYGWIN__)struct timespec ts;clock_gettime(CLOCK_MONOTONIC, &ts);return (uint64_t)((uint64_t)ts.tv_nsec + (uint64_t)ts.tv_sec * BILLION);
#elif defined(_WIN32) || defined(UNDER_CE)LARGE_INTEGER ln;QueryPerformanceCounter(&ln);return (uint64_t)ln.QuadPart;
#endif
}int main(){tmsStart = get_perf_count();// xxxtmsEnd = get_perf_count();msVal = (tmsEnd - tmsStart)/1000000;usVal = (tmsEnd - tmsStart)/1000;
}

好像还是没啥用,貌似是图片没打开?加一行试试看

    if(bmpFile == NULL){printf("File Open Error");}

果然,图片路径设置错误了,打错路径了

input tensor 生成了


补充下模型转换过程:

1) 导入模型

pegasus import darknet --model yolov3.cfg --weights yolov3.weights --output-model yolov3.json --output-data yolov3.data

2)创建 YML 文件对网络的输入和输出的超参数进行描述以及配置

pegasus generate inputmeta --model yolov3.json --input-meta-output yolov3_inputmeta.yml
pegasus generate postprocess-file --model yolov3.json --postprocess-file-output yolov3_postprocessmeta.yml

3)量化

pegasus quantize --model yolov3.json --model-data yolov3.data --batch-size 1 --device CPU --with-input-meta yolov3_inputmeta.yml --rebuild --model-quantize yolov3.quantize --quantizer asymmetric_affine --qtype uint8

4)预推理

pegasus inference --model yolov3.json --model-data yolov3.data --batch-size 1 --dtype quantized --model-quantize yolov3.quantize --device CPU --with-input-meta yolov3_inputmeta.yml --postprocessfile yolov3_postprocessmeta.yml

5)导出模型

pegasus export ovxlib --model yolov3.json --model-data yolov3.data --dtype quantized --model-quantize yolov3.quantize --batch-size 1 --save-fused-graph --target-ide-project 'linux64' --with-input-meta yolov3_inputmeta.yml --output-path ovxilb/yolov3/yolov3prj --pack-nbg-unify --postprocess-file yolov3_postprocessmeta.yml --optimize "VIP9000PICO_PID0XEE" --viv-sdk ${VIV_SDK}

编译了vpm_run作为板子的运行器

make -f makefile.linux

成功运行npu,网络yolov3

root@TinaLinux:/mnt/UDISK# ./vpm_run sample.txt
vpm_run sample.txt loop_run_coun[  720.963277] npu[4a6][4a6] vipcore, device ini                                                                                                                         t..
t device_idsample.txt: to[  720.971229] set_vip_power_clk ONinclude one ore more network bi[  720.979698] enter aw vip mem alloc size 10485                                                                                                                         76
nary graph (NBG) data file resou[  720.985630] aw_vip_mem_alloc vir 0xe2101000,                                                                                                                          phy 0x48d00000
rce.  See sample.txt for details[  720.994403] npu[4a6][4a6] gckvip_drv_init  ke                                                                                                                         rnel logical phy address=0x48d00000  virtual =0xe2101000
.
loop_run_count: the number of loop run network.
device_id: specify this NBG runs device.
example: ./vpm_run sample.txt 1 1, specify the NBG runs on device 1../vpm_run sample.txt 1000, run this network 1000 times.test started.init vip lite, driver version=0x00010800...
[0x4dd08]vip_init[104],
The version of Viplite is: 1.8.0-0-AW-2022-04-21
vip lite init OK.cid=0xee, device_count=1device[0] core_count=1
init test resources, batch_count: 1 ...
create/prepare networks ...
batch i=0, binary name: ./network_binary.nb
[  721.472066] enter aw vip mem alloc size 38656768
[  721.499090] aw_vip_mem_alloc vir 0xe2202000, phy 0x48e00000
input 0 dim 320 320 3 1, data_fo[  721.574304] enter aw vip mem alloc size 49162                                                                                                                         24
rmat=2, quant_format=2, name=input[0], scale=0.003900, zero_poin[  721.584850] a                                                                                                                         w_vip_mem_alloc vir 0xe46e1000, phy 0x4b300000
t=0
ouput 0 dim 10 10 255 1, data_format=2, name=uid_198_out_0, scale=0.100275, zero                                                                                                                         _point=196
ouput 1 dim 20 20 255 1, data_format=2, name=uid_224_out_0, scale=0.103535, zero                                                                                                                         _point=201
ouput 2 dim 40 40 255 1, data_format=2, name=uid_250_out_0, scale=0.140436, zero                                                                                                                         _point=218
nbg name=./network_binary.nb
create network 3: 102471 us.
memory pool size=4916224byte
input 0 name: ./input_0.dat
prepare network 0: 27407 us.
batch: 0, loop count: 1
start to run network=./network_binary.nb
run time for this network 0: 107790 us.
run network done...
profile inference time=107636us, cycle=55530353
******* nb TOP5 ********--- Top5 ---
17545: 5.815971
17546: 5.214319
17555: 5.214319
17544: 5.013768
17554: 4.813218
******* nb TOP5 ********--- Top5 ---
12991: 5.176749
13011: 4.969679
2095: 4.348469
12992: 4.348469
46991: 4.348469
******* nb TOP5 ********--- Top5 ---[  723.594634] aw_vip_mem_free vir 0xe46e1000, phy 0x4b30000051983: 5.196128
187983: 5.055[  723.600977] aw_vip_mem_free dma_unmap_sg_atrs
693
188023: 5.055693
51984: 4.[  723.608738] aw_vip_mem_free ion_unmap_kernel
493949
52023: 4.213077
[  723.616315] aw_vip_mem_free ion_free
[  723.622426] aw_vip_mem_free ion_client_destroy
[  723.630841] aw_vip_mem_free vir 0xe2202000, phy 0x48e00000
[  723.637162] aw_vip_mem_free dma_unmap_sg_atrs
[  723.642126] aw_vip_mem_free ion_unmap_kernel
[  723.651382] aw_vip_mem_free ion_free
[  723.655482] aw_vip_mem_free ion_client_destroy
destroy teset resource batch_count=1
[  723.708967] npu[4a6][4a6] gckvip_drv_exit, aw_vip_mem_free
[  723.715276] aw_vip_mem_free vir 0xe2101000, phy 0x48d00000
[  723.721422] aw_vip_mem_free dma_unmap_sg_atrs
[  723.726398] aw_vip_mem_free ion_unmap_kernel
[  723.731221] aw_vip_mem_free ion_free
[  723.735279] aw_vip_mem_free ion_client_destroy
[  723.740762] npu[4a6][4a6] vipcore, device un-init..

原贴链接:https://bbs.aw-ol.com/topic/1641/
作者@YterAA
全志及开发者最新动态可以关注全志在线微信公众号

全志V853 NPU 踩坑记录相关推荐

  1. NanoPi-M1 Plus(全志H3)踩坑记录

    NanoPi-M1 Plus(全志H3)踩坑记录 未带有遥控器 使用之前NanoPi-T2的遥控器,通用: 分辨率不正确 设备->画面设置->缩小95% 即可: 无法使用tinyalsa ...

  2. 为Jupyter notebook配置R kernel过程及踩坑记录

    为Jupyter notebook配置R kernel过程及踩坑记录 注意:本文为作者安装过程及折腾的过程,内容比较冗杂,如果读者想直接创建一个属于自己的子环境则参考: 如下文章: anaconda下 ...

  3. Python打包工具Pyintealler打包py文件为windows exe文件过程及踩坑记录+实战例子

    Python打包工具Pyintealler打包py文件为windows exe文件过程及踩坑记录+实战例子 目录 Python打包工具Pyintealler打包py文件为windows exe文件过程 ...

  4. TVM: Deep Learning模型的优化编译器(强烈推荐, 附踩坑记录)

    本文作者是阿莱克西斯,原载于知乎,雷锋网(公众号:雷锋网)获得授权转载. (前排提醒,本文的人文内容部分稍稍带有艺术加工,请保持一定的幽默感进行阅读) 关注我最近想法的同学应该知道我最近都在把玩 TV ...

  5. 使用Java读取 “Python写入redis” 的数据踩坑记录

    https://my.oschina.net/u/2338224/blog/3061507 使用Java读取 "Python写入redis" 的数据踩坑记录 https://seg ...

  6. osx php7 imagick,[PHP] MacOS 自带php环境安装imagick扩展踩坑记录 | 码农部落

    前言 最近学习yii2,在搭建环境后,发现在访问contact页面时报错,如下: "Either GD PHP extension with FreeType support or Imag ...

  7. vue-i18n使用及踩坑记录

    使用步骤 1. 安装 npm i vue-i18n 2. vue-cli下使用 //1. 引入 vue-i18n import Vue from 'vue' import VueI18n from ' ...

  8. SpringBoot踩坑记录 Invalid bound statement (not found)引发的一些列问题

    SpringBoot踩坑记录 Invalid bound statement (not found)引发的一些列问题 当你开开心心搭建了一个SpringBoot项目,用插件生成了entity.dao. ...

  9. mysql 使用sum limit_mysql踩坑记录之limit和sum函数混合使用问题

    问题复盘 本次复盘会用一个很简单的订单表作为示例. 数据准备 订单表建表语句如下(这里偷懒了,使用了自增ID,实际开发中不建议使用自增ID作为订单ID) CREATE TABLE `order` ( ...

最新文章

  1. 9月,最值得看的30篇肠道健康文献!
  2. mysql深入浅出_《深入浅出mysql》学习笔记
  3. PhpStorm 中文设置教程
  4. CTFshow 命令执行 web30
  5. xmta温度控制仪说明书_XMT系列数显温度控制器使用说明书
  6. IDEA上Debug调试全流程
  7. java 最小生成树_图的最小生成树(java实现)
  8. c语言a b的和 不用加号,力扣(LeetCode)刷题,简单题(第16期)
  9. DateTimePicker 控件置空
  10. iOS开发之iPhone手机轻松获取UDID的六种方式
  11. [wcf]入门.3.1
  12. python 中的[::-1]和[:-1]
  13. python爬虫破解大众点评的字体加密
  14. 麦肯锡:数字化转型四步法
  15. NMS 非极大值抑制原理及实现
  16. MarkDown快捷教程
  17. mysql rand_mysql rand()产生随机整数范围及方法
  18. 教你制作第一个C++游戏!#1 引入
  19. 虹科教您|实现OPC UA C/S快速部署及数据采集
  20. 通过 TokenType(){}.getType()获取Persionlt;Tgt; 泛型T的类型和数值

热门文章

  1. 【数字化十大预测】德勤发布《2019科技、传媒和电信行业预测》
  2. 阿里巴巴十亿级并发系统设计手册已开源(2021最新版)
  3. 软甲开发的瀑布模型,快速原型型,螺旋型,敏捷开发
  4. 护眼台灯的色温是多少比较好?2022年真的能护眼的护眼灯推荐
  5. 第三方软件测试APP测试点总结
  6. (转载)Xmind 8 pro 软件破解版安装过程
  7. 前端面试--自我介绍
  8. 自动脚本引流怎么样?脚本引流靠谱吗?
  9. JavaScript嵌入HTML文档
  10. 关于高压开关柜在线测温方案的应用探讨