Toybrick

使用pre_compile=True building model失败

jjcz

注册会员

积分
51
QQ
楼主
发表于 2021-12-21 11:55:43    查看: 5046|回复: 2 | [复制链接]    打印 | 只看该作者
在rknn.build设置pre_compile=True后,报错。设置代码节选如下:
  1.         # Build model
  2.         print('--> Building model')
  3.         ret = rknn.build(do_quantization=True, pre_compile=True, dataset='./dataset.txt')
  4.         if ret != 0:
  5.             print('build model failed.')
  6.             exit(ret)
  7.         print('done')
复制代码

报错结果如下:

  1.     (venv) wenji-G3:~/rv1109/external/rknn-toolkit/examples/darknet/yolov3_rknn$ python test.py
  2.     --> Loading model
  3.     done
  4.     --> Building model
  5.     W The RKNN Model generated can not run on simulator when pre_compile is True.
  6.     make: gcc-linaro-6.3.1-2017.05-i686_aarch64-linux-gnugcc: Command not found
  7.     make: *** [vnn_pre_process.o] Error 127
  8.     /bin/sh: 1: /tmp/tmp0s82ra97/gen_nbg: not found
  9.     mv: 无法获取'/home/rv1109/external/rknn-toolkit/examples/darknet/yolov3_rknn/*.nb' 的文件状态(stat): 没有那个文件或目录
  10.     mv: 无法获取'/home/rv1109/external/rknn-toolkit/examples/darknet/yolov3_rknn/*.dat' 的文件状态(stat): 没有那个文件或目录
  11.     E Generate nbg failed.
  12.     W ----------------Warning(1)----------------
  13.     E Catch exception when building RKNN model!
  14.     E Traceback (most recent call last):
  15.     E File "rknn/base/ovxconfiggenerator.py", line 193, in rknn.base.ovxconfiggenerator.generate_vx_config_from_files
  16.     E File "rknn/base/RKNNlib/app/exporter/ovxlib_case/casegenerator.py", line 632, in rknn.base.RKNNlib.app.exporter.ovxlib_case.casegenerator.CaseGenerator.generate
  17.     E File "rknn/base/RKNNlib/app/exporter/ovxlib_case/casegenerator.py", line 583, in rknn.base.RKNNlib.app.exporter.ovxlib_case.casegenerator.CaseGenerator._gen_special_case
  18.     E File "rknn/base/RKNNlib/app/exporter/ovxlib_case/casegenerator.py", line 548, in rknn.base.RKNNlib.app.exporter.ovxlib_case.casegenerator.CaseGenerator._gen_nb_file
  19.     E AttributeError: 'CaseGenerator' object has no attribute 'nbg_graph_file_path'
  20.     E During handling of the above exception, another exception occurred:
  21.     E Traceback (most recent call last):
  22.     E File "rknn/api/rknn_base.py", line 601, in rknn.api.rknn_base.RKNNBase.build
  23.     E File "rknn/api/rknn_base.py", line 414, in rknn.api.rknn_base.RKNNBase._build
  24.     E File "rknn/base/ovxconfiggenerator.py", line 195, in rknn.base.ovxconfiggenerator.generate_vx_config_from_files
  25.     E File "rknn/api/rknn_log.py", line 312, in rknn.api.rknn_log.RKNNLog.e
  26.     E ValueError: Generate nbg failed.
  27.     build model failed.


复制代码
/tmp 目录下无  tmp0s82ra97/gen_nbg  请问这个目录文件如何生成的?需要自己添加吗?在sdk中有没有?
/home/rv1109/external/rknn-toolkit/examples/darknet/yolov3_rknn/*.nb'及 /*.dat  两个文件也不存在,这两个文件需要获取吗?如何获取?

看了《Rockchip_Trouble_Shooting_RKNN_Toolkit_V1.4.0_CN.pdf》中关于rknn.build()设置pre_compile=True报错,其中写道需要确认
请确认:
1) 系统装有 gcc 编译工具链
2) 模型的名称只包含“字母”、“数字”、“_”,特别注意有些复制过来的模型名称
会自动加上”(1)”,这时会失败。也可以升级到 1.3.0 或之后的版本,由 RKNN Toolkit 自
动处理这些特殊字符。
如果不属于上述情况,可以尝试使用 export_rknn_precompile_model 接口从板子上导出
预编译模型。
系统为ubuntu18.04装有gcc,rknn-toolkit  1.6.0,

使用export_rknn_precompile_model的代码如下:
  1.     print('--> init runtime')
  2.     # ret = rknn.init_runtime()
  3.     ret = rknn.init_runtime(target='rv1126', device_id='3166854b086a700f', rknn2precompile=True)
  4.     if ret != 0:
  5.         print('init runtime failed.')
  6.         exit(ret)
  7.     print('done')



  8.     print('--> export pre-compile model')
  9.     # Note:the rknn2precompile must be set True when call init_runtime
  10.     ret = rknn.export_rknn_precompile_model('./test_pre_compile.rknn')
  11.     if ret != 0:
  12.         print('export pre-compile model failed.')
  13.         exit(ret)


  14.     rknn.release()
复制代码
仍然报上述错误,如下所示:
  1. (venv) wenji-G3:~/rv1109/external/rknn-toolkit/examples/darknet/yolov3_rknn$ python test.py
  2. --> Loading model
  3. done
  4. --> Building model
  5. W The RKNN Model generated can not run on simulator when pre_compile is True.
  6. make: gcc-linaro-6.3.1-2017.05-i686_aarch64-linux-gnugcc: Command not found
  7. make: *** [vnn_pre_process.o] Error 127
  8. /bin/sh: 1: /tmp/tmp0s82ra97/gen_nbg: not found
  9. mv: 无法获取'/home/rv1109/external/rknn-toolkit/examples/darknet/yolov3_rknn/*.nb' 的文件状态(stat): 没有那个文件或目录
  10. mv: 无法获取'/home/rv1109/external/rknn-toolkit/examples/darknet/yolov3_rknn/*.dat' 的文件状态(stat): 没有那个文件或目录
  11. E Generate nbg failed.
  12. W ----------------Warning(1)----------------
  13. E Catch exception when building RKNN model!
  14. E Traceback (most recent call last):
  15. E File "rknn/base/ovxconfiggenerator.py", line 193, in rknn.base.ovxconfiggenerator.generate_vx_config_from_files
  16. E File "rknn/base/RKNNlib/app/exporter/ovxlib_case/casegenerator.py", line 632, in rknn.base.RKNNlib.app.exporter.ovxlib_case.casegenerator.CaseGenerator.generate
  17. E File "rknn/base/RKNNlib/app/exporter/ovxlib_case/casegenerator.py", line 583, in rknn.base.RKNNlib.app.exporter.ovxlib_case.casegenerator.CaseGenerator._gen_special_case
  18. E File "rknn/base/RKNNlib/app/exporter/ovxlib_case/casegenerator.py", line 548, in rknn.base.RKNNlib.app.exporter.ovxlib_case.casegenerator.CaseGenerator._gen_nb_file
  19. E AttributeError: 'CaseGenerator' object has no attribute 'nbg_graph_file_path'
  20. E During handling of the above exception, another exception occurred:
  21. E Traceback (most recent call last):
  22. E File "rknn/api/rknn_base.py", line 601, in rknn.api.rknn_base.RKNNBase.build
  23. E File "rknn/api/rknn_base.py", line 414, in rknn.api.rknn_base.RKNNBase._build
  24. E File "rknn/base/ovxconfiggenerator.py", line 195, in rknn.base.ovxconfiggenerator.generate_vx_config_from_files
  25. E File "rknn/api/rknn_log.py", line 312, in rknn.api.rknn_log.RKNNLog.e
  26. E ValueError: Generate nbg failed.
  27. build model failed.
复制代码

请问这种情况应该如何解决?

回复

使用道具 举报

jefferyzhang

版主

积分
13574
沙发
发表于 2021-12-21 12:31:37 | 只看该作者
make: gcc-linaro-6.3.1-2017.05-i686_aarch64-linux-gnugcc: Command not found
回复

使用道具 举报

jjcz

注册会员

积分
51
QQ
板凳
 楼主| 发表于 2021-12-21 17:47:03 | 只看该作者
已发现是编译器的问题,在环境里看到
export PATH=$PATH:~/rv1109/external/RKNPUTools/rknn-api/Linux/rknn_api_sdk/gcc-linaro-6.3.1-2017.05-i686_aarch64-linux-gnu/bin
export PATH=$PATH:~/rv1109/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin
环境路径没有问题,在rv1109目录下搜索各种build.sh文件中,没有发现gcc-linaro-6.3.1-2017.05-i686_aarch64-linux-gnugcc这个路径,都是上边两条正确的路径,报错的编译器后缀带有gcc。请问我该如何解决这个问题?
回复

使用道具 举报

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

本版积分规则

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


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