Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Rock3/dev/npu-run-test"

< Rock3‎ | dev
(Step 2: Get RKNN2 SSD DEMO)
m
 
(6 intermediate revisions by one other user not shown)
Line 7: Line 7:
 
=== Description ===
 
=== Description ===
  
SoC RK3568 is equipped with 0.8TOPS NPU. This tutorial shows how to make the NPU run on ROCK 3 A, and provides an example and test results.
+
SoC RK3568 is equipped with 0.8TOPS NPU. This tutorial shows how to make the NPU run on ROCK 3A, and provides an example and test results.
  
 
=== Hardware supported ===
 
=== Hardware supported ===
  
* ROCK 3 A
+
* ROCK 3A
 +
* ROCK 3B
 
* Radxa CM3 IO Board
 
* Radxa CM3 IO Board
 
* Radxa E23
 
* Radxa E23
 +
* Radxa E25
  
 
Now follow me to make the NPU run.
 
Now follow me to make the NPU run.
Line 21: Line 23:
 
==== Step 1: Get system image  ====
 
==== Step 1: Get system image  ====
  
You can get system image from [https://github.com/radxa/rock-3-images-released/releases ROCK 3 A System images].
+
You can get system image from [https://github.com/radxa/rock-3-images-released/releases ROCK 3A System images].
  
Here we are concerned about the kernel version. Make sure that kernel is at least  4.19.193-17-rockchip.
+
Here we are concerned about the kernel version. Make sure that kernel is at least  4.19.193-25-rockchip.
  
  root@rock-3a:/home/rock# uname -a
+
  root@rock-3a:/home/rock# uname -r
  Linux rock-3a 4.19.193-17-rockchip-ga4e78ea509f7 #rockchip SMP Fri Nov 19 16:59:52 CST 2021 aarch64 GNU/Linux
+
  4.19.193-25-rockchip-g56fae2db273e
  
 
If not, try to upgrade the kernel via the following commands.
 
If not, try to upgrade the kernel via the following commands.
Line 56: Line 58:
 
  root@rock-3a:/home/rock# apt install -y curl
 
  root@rock-3a:/home/rock# apt install -y curl
  
Get rknn_ssd_demo_Linux.zip package,  check the md5 of file. It should be 51d85886553225923790dd1ab895f54f.
+
Get rknn_ssd_demo_Linux.zip package,  check the md5 of file. It should be b03a1b3c236b83def933090c846d24f5.
 
And extract it.
 
And extract it.
  
root@rock-3a:/home/rock# curl https://dl.radxa.com/rock3/npu/rknn_ssd_demo_Linux.zip > rknn_ssd_demo_Linux.zip
+
<pre>
root@rock-3a:/home/rock# md5sum rknn_ssd_demo_Linux.zip
+
root@rock-3a:/home/rock# curl https://dl.radxa.com/rock3/npu/rknn_ssd_demo_linux_20220728.tar.gz > rknn_ssd_demo_linux_20220728.tar.gz
  51d85886553225923790dd1ab895f54f  rknn_ssd_demo_Linux.zip
+
root@rock-3a:/home/rock# md5sum rknn_ssd_demo_linux_20220728.tar.gz
root@rock-3a:/home/rock# unzip rknn_ssd_demo_Linux.zip
+
f8ed06c1409155ab0bbe08dc27430463 rknn_ssd_demo_linux_20220728.tar.gz
 +
root@rock-3a:/home/rock# tar zxvf rknn_ssd_demo_linux_20220728.tar.gz
 +
</pre>
  
Check RKNN runtime version. Here it is '''1.1.0'''.
+
Check RKNN runtime version. Here it is '''1.3.0'''.
 
<pre>
 
<pre>
 
root@rock-3a:/home/rock# cd rknn_ssd_demo_Linux
 
root@rock-3a:/home/rock# cd rknn_ssd_demo_Linux
 
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# strings lib/librknnrt.so | grep version
 
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# strings lib/librknnrt.so | grep version
librknnrt version: 1.1.0 (8a9d6f66@2021-08-19T15:09:11)
+
librknnrt version: 1.3.0 (9b36d4d74@2022-05-04T20:17:01)
 
rknn_query, info_len(%d) != sizeof(rknn_sdk_version)(%d)!
 
rknn_query, info_len(%d) != sizeof(rknn_sdk_version)(%d)!
RKNN Driver Information: version: %d.%d.%d
+
model version < 3, cannot query RKNN_QUERY_NATIVE_NHWC_OUTPUT_ATTR
Mismatch driver version, %s requires driver version >= %d.%d.%d, but you have driver version: %d.%d.%d which is incompatible!
+
unsupported file format version
Current driver version: %d.%d.%d, recommend to upgrade the driver to the new version: >= %d.%d.%d
+
wrong version
+
 
Invalid RKNN model version  
 
Invalid RKNN model version  
 +
RKNN Model Information: version: %d, toolkit version: %s, target: %s, target platform: %s, framework name: %s, framework layout: %s
 +
failed to check rknpu hardware version: %#x
 +
The rknn model does not match the RKNPU hardware version!
 
RKNN Model version: %d.%d.%d not match with rknn runtime version: %d.%d.%d
 
RKNN Model version: %d.%d.%d not match with rknn runtime version: %d.%d.%d
RKNN Model Information: version: %d, toolkit version: %s, target platform: %s, framework name: %s, framework layout: %s
 
version
 
 
Generated from compiler version:  
 
Generated from compiler version:  
 
(compiler version:  
 
(compiler version:  
 +
RKNN Driver Information: version: %d.%d.%d
 +
Mismatch driver version, %s requires driver version >= %d.%d.%d, but you have driver version: %d.%d.%d which is incompatible!
 +
Current driver version: %d.%d.%d, recommend to upgrade the driver to the new version: >= %d.%d.%d
 +
wrong version
 
incompatible version
 
incompatible version
 
.gnu.version
 
.gnu.version
Line 91: Line 98:
 
<pre>
 
<pre>
 
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# export LD_LIBRARY_PATH=./lib/
 
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# export LD_LIBRARY_PATH=./lib/
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# chmod +x rknn_ssd_demo
+
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# ./rknn_ssd_demo model/RK356X/ssd_inception_v2.rknn model/bus.jpg
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# ./rknn_ssd_demo model/ssd_inception_v2.rknn model/road.bmp
+
resize 640 640 to 300 300
 
Loading model ...
 
Loading model ...
 
rknn_init ...
 
rknn_init ...
 
model input num: 1, output num: 2
 
model input num: 1, output num: 2
 
input tensors:
 
input tensors:
index=0 name=Preprocessor/sub:0 n_dims=4 dims=[1 300 300 3] n_elems=270000 size=270000 fmt=0 type=3 qnt_type=2 fl=0 zp=0 scale=0.007812
+
  index=0, name=Preprocessor/sub:0, n_dims=4, dims=[1, 300, 300, 3], n_elems=270000, size=270000, fmt=NHWC, type=UINT8, qnt_type=AFFINE, zp=0, scale=0.007812
 
output tensors:
 
output tensors:
index=0 name=concat:0 n_dims=4 dims=[1 1917 1 4] n_elems=7668 size=30672 fmt=0 type=0 qnt_type=2 fl=0 zp=53 scale=0.089455
+
  index=0, name=concat:0, n_dims=4, dims=[1, 1917, 1, 4], n_elems=7668, size=30672, fmt=NCHW, type=FP32, qnt_type=AFFINE, zp=53, scale=0.089455
index=1 name=concat_1:0 n_dims=4 dims=[1 1917 91 1] n_elems=174447 size=697788 fmt=0 type=0 qnt_type=2 fl=0 zp=53 scale=0.143593
+
  index=1, name=concat_1:0, n_dims=4, dims=[1, 1917, 91, 1], n_elems=174447, size=697788, fmt=NCHW, type=FP32, qnt_type=AFFINE, zp=53, scale=0.143593
 
rknn_run
 
rknn_run
 
loadLabelName
 
loadLabelName
 
ssd - loadLabelName ./model/coco_labels_list.txt
 
ssd - loadLabelName ./model/coco_labels_list.txt
 
loadBoxPriors
 
loadBoxPriors
person @ (13 125 59 212) 0.984696
+
person @ (107 241 217 532) 0.994344
person @ (110 119 152 197) 0.969119
+
bus @ (87 132 567 433) 0.989999
bicycle @ (171 165 278 234) 0.969119
+
person @ (211 225 290 513) 0.829137
person @ (206 113 256 216) 0.964519
+
car @ (146 133 216 170) 0.959264
+
person @ (49 133 58 156) 0.606060
+
person @ (83 134 92 158) 0.606060
+
person @ (96 135 106 162) 0.464163
+
root@rock-3a:/home/rock/rknn_ssd_demo_Linux
+
 
</pre>
 
</pre>
  
 
You would also get the output image, out.jpg, under /home/rock/rknn_ssd_demo_Linux directory.
 
You would also get the output image, out.jpg, under /home/rock/rknn_ssd_demo_Linux directory.
  
[[File:rock3a-npu-test-road-out.jpg | 440px ]]
+
[[File:rock-3a-npu-test-bus-out.jpg | 440px ]]
 +
 
 +
==== Step4: Run Your Own Built RKNPU Demo ====
 +
 
 +
You can get more rknpu demo from [https://github.com/radxa/rknpu2 RK356X NPU SDK].
  
 
=== Troubleshooting ===
 
=== Troubleshooting ===
  
 
Check [[rock3/FAQs |ROCK 3 FAQs]] first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/rock3.
 
Check [[rock3/FAQs |ROCK 3 FAQs]] first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/rock3.

Latest revision as of 02:03, 7 February 2023

    ROCK 3 >  Development >  NPU Run Test

Description

SoC RK3568 is equipped with 0.8TOPS NPU. This tutorial shows how to make the NPU run on ROCK 3A, and provides an example and test results.

Hardware supported

  • ROCK 3A
  • ROCK 3B
  • Radxa CM3 IO Board
  • Radxa E23
  • Radxa E25

Now follow me to make the NPU run.

Setup steps

Step 1: Get system image

You can get system image from ROCK 3A System images.

Here we are concerned about the kernel version. Make sure that kernel is at least 4.19.193-25-rockchip.

root@rock-3a:/home/rock# uname -r
4.19.193-25-rockchip-g56fae2db273e

If not, try to upgrade the kernel via the following commands.

Uncomment "deb http://apt.radxa.com/buster-testing/ buster main" in file /etc/apt/sources.list.d/apt-radxa-com.list. Here I use debian buster image. So its content is

deb http://apt.radxa.com/buster-stable/ buster main
deb http://apt.radxa.com/buster-testing/ buster main

If you use ubuntu focal image, It should be like this

deb http://apt.radxa.com/focal-stable/ focal main
deb http://apt.radxa.com/focal-testing/ focal main

After saving that file, now we install the latest kernel packages.

root@rock-3a:/home/rock# apt update
root@rock-3a:/home/rock# apt install -y linux-4.19-rock-3-latest

Then reboot the device. Use command 'uname -a' to check the kernel verison again.

Step 2: Get Prebuilt RKNN2 SSD DEMO

Install curl tool.

root@rock-3a:/home/rock# apt update
root@rock-3a:/home/rock# apt install -y curl

Get rknn_ssd_demo_Linux.zip package, check the md5 of file. It should be b03a1b3c236b83def933090c846d24f5. And extract it.

root@rock-3a:/home/rock# curl https://dl.radxa.com/rock3/npu/rknn_ssd_demo_linux_20220728.tar.gz > rknn_ssd_demo_linux_20220728.tar.gz
root@rock-3a:/home/rock# md5sum rknn_ssd_demo_linux_20220728.tar.gz 
f8ed06c1409155ab0bbe08dc27430463  rknn_ssd_demo_linux_20220728.tar.gz
root@rock-3a:/home/rock# tar zxvf rknn_ssd_demo_linux_20220728.tar.gz

Check RKNN runtime version. Here it is 1.3.0.

root@rock-3a:/home/rock# cd rknn_ssd_demo_Linux
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# strings lib/librknnrt.so | grep version
librknnrt version: 1.3.0 (9b36d4d74@2022-05-04T20:17:01)
rknn_query, info_len(%d) != sizeof(rknn_sdk_version)(%d)!
model version < 3, cannot query RKNN_QUERY_NATIVE_NHWC_OUTPUT_ATTR
unsupported file format version
Invalid RKNN model version 
RKNN Model Information: version: %d, toolkit version: %s, target: %s, target platform: %s, framework name: %s, framework layout: %s
failed to check rknpu hardware version: %#x
The rknn model does not match the RKNPU hardware version!
RKNN Model version: %d.%d.%d not match with rknn runtime version: %d.%d.%d
Generated from compiler version: 
(compiler version: 
RKNN Driver Information: version: %d.%d.%d
Mismatch driver version, %s requires driver version >= %d.%d.%d, but you have driver version: %d.%d.%d which is incompatible!
Current driver version: %d.%d.%d, recommend to upgrade the driver to the new version: >= %d.%d.%d
wrong version
incompatible version
.gnu.version
.gnu.version_r

Step3: Run RKNN2 SSD DEMO

These are test commands and result.

root@rock-3a:/home/rock/rknn_ssd_demo_Linux# export LD_LIBRARY_PATH=./lib/
root@rock-3a:/home/rock/rknn_ssd_demo_Linux# ./rknn_ssd_demo model/RK356X/ssd_inception_v2.rknn model/bus.jpg
resize 640 640 to 300 300
Loading model ...
rknn_init ...
model input num: 1, output num: 2
input tensors:
  index=0, name=Preprocessor/sub:0, n_dims=4, dims=[1, 300, 300, 3], n_elems=270000, size=270000, fmt=NHWC, type=UINT8, qnt_type=AFFINE, zp=0, scale=0.007812
output tensors:
  index=0, name=concat:0, n_dims=4, dims=[1, 1917, 1, 4], n_elems=7668, size=30672, fmt=NCHW, type=FP32, qnt_type=AFFINE, zp=53, scale=0.089455
  index=1, name=concat_1:0, n_dims=4, dims=[1, 1917, 91, 1], n_elems=174447, size=697788, fmt=NCHW, type=FP32, qnt_type=AFFINE, zp=53, scale=0.143593
rknn_run
loadLabelName
ssd - loadLabelName ./model/coco_labels_list.txt
loadBoxPriors
person @ (107 241 217 532) 0.994344
bus @ (87 132 567 433) 0.989999
person @ (211 225 290 513) 0.829137

You would also get the output image, out.jpg, under /home/rock/rknn_ssd_demo_Linux directory.

Rock-3a-npu-test-bus-out.jpg

Step4: Run Your Own Built RKNPU Demo

You can get more rknpu demo from RK356X NPU SDK.

Troubleshooting

Check ROCK 3 FAQs first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/rock3.