瑞芯微 Rockchip rknn 模型在线预编译
flyfish
主机Host环境
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
开发板Target环境
RV1126
一 主机连接开发板
用线连起来后,查看usb信息
没权限的提示
no permissions (user in plugdev group; are your udev rules wrong?); see [http://developer.android.com/tools/device.html]
解决方法
新建一个名为update_rv1126_usb_rule.sh的文件
update_rv1126_usb_rule.sh的内容如下
cat <<EOF > "91-rv1126-ai-cs.rules"
SUBSYSTEM=="usb", ATTR{idVendor}=="2207", MODE="0666"
EOF
sudo cp -f 91-rv1126-ai-cs.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo ldconfig
rm 91-rv1126-ai-cs.rules
然后执行
sudo ./update_rv1126_usb_rule.sh
2207是通过lsusb命令查看的idVender是厂商标识
MODE是设备权限
(666) 所有用户都有文件读、写权限,也可以换成
(777) 所有用户都有读、写、执行权限。
重新插拔下
没有了没有权限的提示
二 在线预编译模型
# -*- coding: utf-8 -*-
import sys
#if __name__ == '__main__':
if len(sys.argv) != 3:
print('Usage: python {} xxx.rknn xxx.hw.rknn'.format(sys.argv[0]))
print('Such as: python {} yolov5.rknn yolov5.pre.rknn'.format(sys.argv[0]))
exit(1)
from rknn.api import RKNN
orig_rknn = sys.argv[1]
hw_rknn = sys.argv[2]
# Create RKNN object
rknn = RKNN()
# Load rknn model
print('--> Loading RKNN model')
ret = rknn.load_rknn(orig_rknn)
if ret != 0:
print('Load RKNN model failed!')
exit(ret)
print('done')
# Init runtime environment
print('--> Init runtime environment')
ret = rknn.init_runtime(target='rv1126', rknn2precompile=True)
if ret != 0:
print('Init runtime environment failed')
exit(ret)
print('done')
ret = rknn.export_rknn_precompile_model(hw_rknn)
rknn.release()
使用实例
python rknn_precompile.py yolov5.rknn yolov5.pre.rknn
问题
File "rknn/base/acuitylib/optimize/optimizer.py", line 114, in init rknn.base.acuitylib.optimize.optimizer
File "rknn/base/acuitylib/optimize/rules/hack_for_driver/cumsum_to_conv2d.py", line 1, in init rknn.base.acuitylib.optimize.rules.hack_for_driver.cumsum_to_conv2d
File "/home/a/anaconda3/envs/rknn/lib/python3.6/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/home/a/anaconda3/envs/rknn/lib/python3.6/site-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/home/a/anaconda3/envs/rknn/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: /home/a/anaconda3/envs/rknn/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/a/anaconda3/envs/rknn/lib/python3.6/site-packages/cv2/cv2.abi3.so)
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_3.4.29
GLIBCXX_3.4.30
GLIBCXX_DEBUG_MESSAGE_LENGTH
ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /home/a/anaconda3/envs/rknn/bin/../lib/libstdc++.so.6
测试
遇到的错误
allocator.cc:107] Allocation of 1105920000 exceeds 10% of system memory
设置 rknn.config的batch_size参数