Toybrick

标题: 关于rknn.build(pre_compile=True)遇到的问题 [打印本页]

作者: chuyee    时间: 2019-2-9 09:29
标题: 关于rknn.build(pre_compile=True)遇到的问题
看到文档里提到构建rknn模型时打开pre_compile选项可以减小模型大小,并提升加载速度。试了一下发现调用rknn.build()时出错。错误如下:

[toybrick@localhost mobilenet_v1]$ python test.py
/usr/lib64/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
--> config model
--> Loading model
done
--> Building model
Catch exception when building RKNN model!
Traceback (most recent call last):
  File "/usr/local/lib64/python3.6/site-packages/rknn/api/rknn.py", line 159, in build
    ret = self.rknn_base.build(do_quantization=do_quantization, dataset=dataset, pack_vdata=pre_compile)
  File "rknn/api/redirect_stdout.py", line 67, in rknn.api.redirect_stdout.redirect_stdout.func_wrapper
  File "rknn/api/redirect_stdout.py", line 68, in rknn.api.redirect_stdout.redirect_stdout.func_wrapper
  File "rknn/api/rknn_base.py", line 421, in rknn.api.rknn_base.RKNNBase.build
  File "rknn/api/rknn_base.py", line 375, in rknn.api.rknn_base.RKNNBase._build
  File "rknn/base/ovxconfiggenerator.py", line 146, in rknn.base.ovxconfiggenerator.generate_vx_config_from_files
  File "rknn/base/rknnlib/app/helper/striphelper.py", line 101, in rknn.base.rknnlib.app.helper.striphelper.StripHelper.build_network_2
  File "rknn/base/rknnlib/app/helper/striphelper.py", line 445, in rknn.base.rknnlib.app.helper.striphelper.StripHelper._pack_data
  File "rknn/base/rknnlib/app/helper/vdata_generator.py", line 98, in rknn.base.rknnlib.app.helper.vdata_generator.VDataGenerator.__init__
  File "rknn/base/rknnlib/app/helper/vdata_generator.py", line 243, in rknn.base.rknnlib.app.helper.vdata_generator.VDataGenerator._parse_ovx_vdata
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmptxqioi0k/mobilenet_v1_a.vdata'

Build mobilenet_v1 failed!

我的/tmp下的确没有tmptxqioi0k这个目录。我的代码改动如下:

diff --git a/rknn-toolkit/example/mobilenet_v1/test.py b/rknn-toolkit/example/mobilenet_v1/test.py
index d7fd58f..e00ff48 100644
--- a/rknn-toolkit/example/mobilenet_v1/test.py
+++ b/rknn-toolkit/example/mobilenet_v1/test.py
@@ -43,7 +43,7 @@ if __name__ == '__main__':
     # Build model
     print('--> Building model')
-    ret = rknn.build(do_quantization=True, dataset='./dataset.txt')
+    ret = rknn.build(do_quantization=True, dataset='./dataset.txt', pre_compile=True)
     if ret != 0:
         print('Build mobilenet_v1 failed!')
         exit(ret)
@@ -70,7 +70,8 @@ if __name__ == '__main__':
     img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
     print('--> Init runtime environment')
-    ret = rknn.init_runtime()
+    #ret = rknn.init_runtime()
+    ret = rknn.init_runtime(host='rk3399pro')
     if ret != 0:
         print('Init runtime environment failed')

         exit(ret)


作者: troy    时间: 2019-2-13 10:00
使用pip3 list | grep rknn-toolkit查看下ToolKit的版本
作者: troy    时间: 2019-2-13 11:20
预编译目前只支持在PC上面转换,转换完成的模型可以运行在开发板上。
作者: chuyee    时间: 2019-2-15 09:19
本帖最后由 chuyee 于 2019-2-15 09:24 编辑

rknn 'pre_compile=True' works for x86_64!
The model size is shrinked 1/6 (30M -> 6M). However the inference time is still the same (~0.29s).





欢迎光临 Toybrick (https://t.rock-chips.com/) Powered by Discuz! X3.3