Toybrick

楼主: jefferyzhang

rknn-toolkit & rknn-api for Toybrick

 

marshorizon

注册会员

积分
71
发表于 2021-3-2 10:39:29 | 显示全部楼层
pytorch模型转换报错
在转换openpose的模型时也报错
环境:Ubuntu 18.04  x86,torch 1.6,toolkit 1.6,python 3.6,npu:toybrick 1808,报错信息:
*************************
all device(s) with ntb mode:
TM018084201100261
*************************
([], ['TM018084201100261'])
**************************************************
./kinetics-st_gcn.pt ********************
E Catch exception when loading pytorch model: ./kinetics-st_gcn.pt!
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 339, in rknn.api.rknn_base.RKNNBase.load_pytorch
E   File "rknn/base/RKNNlib/RK_nn.py", line 146, in rknn.base.RKNNlib.RK_nn.RKnn.load_pytorch
E   File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 128, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E   File "rknn/base/RKNNlib/converter/convert_pytorch_new.py", line 2243, in rknn.base.RKNNlib.converter.convert_pytorch_new.convert_pytorch.load
E   File ".../lib/python3.6/site-packages/torch/jit/__init__.py", line 275, in load
E     cpp_module = torch._C.import_ir_module(cu, f, map_location, _extra_files)
E RuntimeError: [enforce fail at inline_container.cc:144] . PytorchStreamReader failed reading zip archive: failed finding central directory
-1
劳驾指点一下

回复

使用道具 举报

Lubagov

注册会员

积分
132
QQ
发表于 2021-3-2 19:50:42 | 显示全部楼层
本帖最后由 Lubagov 于 2021-3-2 20:44 编辑

I was glad to receive an answer, thank you very much!

It seems ASUS is not going to update the API at all. What I have is version 1.3.0 released a year ago in Debain 9, and 1.3.2 in Android.
Even though the firmware was updated in December.

I continue to play with this Debian rootfs, and if use form Debian 10 (NPU FW from ASUS, no other seems to work with it):

If i compile app over with preinstalled libs:
  1. gcc ./main.c -L. -lrknn_api -lpthread
复制代码

  1. D RKNNAPI: ==============================================
  2. D RKNNAPI: RKNN VERSION:
  3. D RKNNAPI:   API: 1.4.0 (bbe0dfc build: 2020-09-14 14:06:05)
  4. D RKNNAPI:   DRV: 1.3.2 (f113d64 build: 2020-04-23 09:35:26)
  5. D RKNNAPI: ==============================================
复制代码

and when i check:

  1. $ strings /usr/lib/aarch64-linux-gnu/librknn_api.so | grep build:
  2. (bbe0dfc build: 2020-09-14 14:06:05
复制代码


When i use Python:

  1. D RKNNAPI: ==============================================
  2. D RKNNAPI: RKNN VERSION:
  3. D RKNNAPI:   API: 1.6.0 (79320de build: 2020-12-29 10:57:09)
  4. D RKNNAPI:   DRV: 1.3.2 (f113d64 build: 2020-04-23 09:35:26)
  5. D RKNNAPI: ==============================================
复制代码


Have small fix it for it can update/download packages fine.
It seems you didn't really want it to be used this image on other boards.
But I am think packages have been updated correctly from your repository.


By the way, the guide in the first post seems a little outdated:
If I execute this command, it becomes very bad:


  1. pip3 install --user -U tensorflow == 1.14.0
复制代码


Version is already preinstalled, 2.0.0 and it works, version 1.14.0 does not work.

But it is not solve my problem, in any case, i have same problem when call `rknn_init`, with any other firmware expect 1.3.2 from ASUS:

in c:

  1. toybrick@debian10:~/test_npu/comp$ ./a.out
  2. E RKNNAPI: rknn_init,  recv(MsgLoadAck) fail, -9(ERROR_PIPE) != 368!
  3. rknn_init fail! ret=-3
  4. Segmentation fault
复制代码


in Python:

  1. toybrick@debian10:~/test_npu$ python3 testapi.py
  2. --> Loading RKNN model
  3. done
  4. I NPUTransfer: Starting NPU Transfer Client, Transfer version 2.1.0 (b5861e7@2020-11-23T11:50:51)
  5. E RKNNAPI: rknn_init,  recv(MsgLoadAck) fail, -9(ERROR_PIPE) != 368!
  6. E Catch exception when init runtime!
  7. E Traceback (most recent call last):
  8. E   File "rknn/api/rknn_base.py", line 844, in rknn.api.rknn_base.RKNNBase.init_runtime
  9. E   File "rknn/api/rknn_runtime.py", line 340, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
  10. E Exception: RKNN init failed. error code: RKNN_ERR_DEVICE_UNAVAILABLE
  11. --> Running model
  12. W We need do some initial work, it will increase call time of inference for the first time.
  13. I NPUTransfer: Starting NPU Transfer Client, Transfer version 2.1.0 (b5861e7@2020-11-23T11:50:51)
  14. E NPUTransfer: Transfer interface open failed!, ret = -1
  15. E RKNNAPI: rknn_init,  driver open fail!  ret = -1(ERROR_IO)!
  16. E Catch exception when init model!
  17. E Traceback (most recent call last):
  18. E   File "rknn/api/rknn_base.py", line 931, in rknn.api.rknn_base.RKNNBase.inference
  19. E   File "rknn/api/rknn_runtime.py", line 340, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
  20. E Exception: RKNN init failed. error code: RKNN_ERR_DEVICE_UNAVAILABLE
  21. done
复制代码
dmesg output in NPU:

  1. [  873.529384] android_work: sent uevent USB_STATE=DISCONNECTED
  2. [  873.530761] configfs-gadget gadget: unbind function 'Function FS Gadget'/ffffffc0052c1e38
  3. [  873.530845] configfs-gadget gadget: unbind function 'Function FS Gadget'/ffffffc0052c1c38
  4. [  873.531441] read descriptors
  5. [  873.531466] read strings
  6. [  874.545684] configfs-gadget fd000000.dwc3: failed to start rockchip: -19
  7. [  874.573016] read descriptors
  8. [  874.573057] read strings
  9. [  874.579310] android_work: did not send uevent (0 0           (null))
  10. [  874.706836] android_work: did not send uevent (0 0           (null))
  11. [  874.788465] android_work: sent uevent USB_STATE=CONNECTED
  12. [  874.819649] configfs-gadget gadget: super-speed config #1: b
  13. [  874.819883] android_work: sent uevent USB_STATE=CONFIGURED
复制代码
回复

使用道具 举报

Lubagov

注册会员

积分
132
QQ
发表于 2021-3-4 21:34:23 | 显示全部楼层
本帖最后由 Lubagov 于 2021-3-5 00:57 编辑

Unpacked from the NPU firmware, boot.img into parts via `imgrepackrk`. And also unpacked the 1.6 firmware from Debain 10 from Toybrick. Replaced the ramdisk in the ASUS firmware with the ramdisk from the Toybrick firmware. Then, I packed it back. those. The kernel and resources are from ASUS, and the ramdisk is from Toybrick. And it works at least `rknn_init` fine call.Better of cose build it from source somehow, and make it working.. Only not clear how to build kernel, working on ASUS...

I NPUTransfer: Starting NPU Transfer Client, Transfer version 2.1.0 (b5861e7@2020-11-23T11:50:51)
D RKNNAPI: ==============================================
D RKNNAPI: RKNN VERSION:
D RKNNAPI:   API: 1.6.0 (79320de build: 2020-12-29 10:57:09)
D RKNNAPI:   DRV: 1.6.0 (159d2d3 build: 2021-01-12 15:23:09)
D RKNNAPI: ==============================================

/=============
I am trying to run the YOLO5 example. I understand correctly that `/dev/card/dri0` should be on the NPU device, but only with the new kernel?
Or, is it on RK1808 but not on RK3399Pro?


  1. # ./run_rk180x.sh
  2. Read model/test2.jpg ...
  3. img width = 1280, img height = 720
  4. Loading mode...
  5. failed to open /dev/dri/card0
  6. sdk version: librknn_runtime version 1.6.0 (096015c build: 2021-01-12 15:25:30 base: 1126) driver version: 6.4.3.5.293908
  7. model input num: 1, output num: 3
  8. index=0 name=images_165 n_dims=4 dims=[1 3 640 640] n_elems=1228800 size=1228800 fmt=0 type=3 qnt_type=2 fl=0 zp=0 scale=0.003922
  9. index=0 name=Conv_Conv_159/out0_0 n_dims=4 dims=[1 255 80 80] n_elems=1632000 size=1632000 fmt=0 type=3 qnt_type=2 fl=-69 zp=187 scale=0.127843
  10. index=1 name=Conv_Conv_160/out0_1 n_dims=4 dims=[1 255 40 40] n_elems=408000 size=408000 fmt=0 type=3 qnt_type=2 fl=-74 zp=182 scale=0.113217
  11. index=2 name=Conv_Conv_161/out0_2 n_dims=4 dims=[1 255 20 20] n_elems=102000 size=102000 fmt=0 type=3 qnt_type=2 fl=-84 zp=172 scale=0.103272
  12. model is NCHW input fmt
  13. model input height=640, width=640, channel=3
  14. failed to open /dev/dri/card0
  15. ./run_rk180x.sh: line 4:   221 Segmentation fault      ./rknn_yolov5_demo model/${chip_dir}/yolov5s_relu_rk180x_out_opt.rknn model/test2.jpg
  16. /userdata/rknn_yolov5_demo # root@debian10:/home/toybrick/yolo5/rknn_yolov5_demo/install#
复制代码

I will be very grateful for the answer where /dev/dri/card0 comes from. I don't have it, on any firmware. This is ok for rk3399pro?




回复

使用道具 举报

小宁哥

注册会员

积分
93
发表于 2021-3-8 15:25:11 | 显示全部楼层
这官方源里torch1.6 的命名有问题吧:torch-1.6.0a0+b31f58d-cp37-cp37m-linux_aarch64.whl ,也没有torchvision
回复

使用道具 举报

jefferyzhang

版主

积分
12921
 楼主| 发表于 2021-3-8 16:32:08 | 显示全部楼层
Lubagov 发表于 2021-3-4 21:34
Unpacked from the NPU firmware, boot.img into parts via `imgrepackrk`. And also unpacked the 1.6 fir ...

/dev/dri/card0  is used for drm.
Try rknn-toolkit-lite ?
回复

使用道具 举报

Lubagov

注册会员

积分
132
QQ
发表于 2021-3-8 18:44:35 | 显示全部楼层
本帖最后由 Lubagov 于 2021-3-9 23:58 编辑

I just try to run this sample, step by step:
https://github.com/rockchip-linu ... es/rknn_yolov5_demo
And on NPU itself have not /dev/dri/card0 (if i open it over `adb shell` to get NPU shell i don't have /dev/dri/*).
SSD sample on last firmware work, but also write about card0 is not here... YOLO5 sample direct work with DRM, and ofcose not work... On 1.3.2 FW, SSD work without any messages. But dri interface also has not....

Seems it was appended to 1.6.0 kernel? And maybe also it dependent new API rknn_inputs_map/rknn_outputs_map, with direct memory access... Why do we need a DRM interface in new firmware? Which is naturally not in the old kernel, becouse kernel i put from old ASUS FW(becouse other kernels not work at all, with that ASUS)... I am right?
======
I ordered TB-RK1808 and TB-RK3399ProD, hopefully I will have them at the end of the month. I will compare and try ...
ASUS is preferred because it is easier to buy in large quantities, and cheaper (180EURO when buying locally). But it makes no sense, to use something where the firmware is not updated....


回复

使用道具 举报

LDSM

新手上路

积分
24
发表于 2021-3-11 11:07:44 | 显示全部楼层

OneDrive的链接打开还是1.4版本的,请更新
回复

使用道具 举报

LDSM

新手上路

积分
24
发表于 2021-3-11 11:58:50 | 显示全部楼层

上面OneDrive的链接还是1.4的呢, 请更新!
回复

使用道具 举报

wateras

注册会员

积分
55
发表于 2021-3-12 09:39:57 | 显示全部楼层
请问下如何在容器中访问3399pro的npu资源呢?我们想把AI算法打包到容器中,不过不清楚如何配置共享宿主机NPU资源。这块可以指点下吗?
回复

使用道具 举报

hezhengting

注册会员

积分
52
发表于 2021-3-15 11:50:48 | 显示全部楼层
请问现在1.6版本的API-SDK有下载了吗?http://repo.rock-chips.com/rk1808/rknn-api/ 这个网页似乎是1.4的。另外一个问题是不知道3288作为安卓上位机,能和rk1808被动模式一起用吗?好像看到SDK对安卓的要求是8.1或以上,但是RK3288的安卓应该是6或者7.1的吧,所以能一起用吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表