Toybrick

楼主: candela4rk

模型推理遇到问题

jefferyzhang

版主

积分
13578
11#
发表于 2020-5-19 12:10:49 | 只看该作者
candela4rk 发表于 2020-5-19 12:04
好像找不到npu,有验证指令吗,我获取不到设备id......

lsusb 看下有没有 0x2207开头的。
你这个应该不是没NPU,之前不是都list出来了。只是你没指定用哪个NPU而已。
我们是支持多计算棒并行计算的,如果同时插了好几个,这时候不就得手动指定
回复

使用道具 举报

candela4rk

注册会员

积分
91
12#
 楼主| 发表于 2020-5-19 17:04:41 | 只看该作者
jefferyzhang 发表于 2020-5-19 12:02
没看明白。。。
现在的错误是啥?如果init runtime说没设备,就是你的init runtime的参数没填对,可以看 ...

我用API,查看设备数是0
E RKNNAPI: rknn_find_devices fail!
n_devices = 0
  1. #include <stdio.h>
  2. #include "rknn_api.h"
  3. #include <pthread.h>

  4. int main()
  5. {
  6.     rknn_devices_id devids;
  7.     rknn_find_devices(&devids);
  8.     printf("n_devices = %d\n", devids.n_devices);
  9.     for (int i = 0; i < devids.n_devices; i++)
  10.     {
  11.         printf("%d: type=%s, id=%s\n", i, devids.types[i], devids.ids[i]);
  12.     }
  13.     return 0;
  14. }
复制代码

回复

使用道具 举报

candela4rk

注册会员

积分
91
13#
 楼主| 发表于 2020-5-19 17:06:25 | 只看该作者
jefferyzhang 发表于 2020-5-19 12:10
lsusb 看下有没有 0x2207开头的。
你这个应该不是没NPU,之前不是都list出来了。只是你没指定用哪个NPU而 ...

Bus 002 Device 003: ID 2207:0019 Fuzhou Rockchip Electronics Company
回复

使用道具 举报

jefferyzhang

版主

积分
13578
14#
发表于 2020-5-19 17:33:07 | 只看该作者
从你lsusb结果来看都是正常的。
请问下你的开发版是谁家的,型号是什么,系统是什么,是3399pro还是1808计算棒
回复

使用道具 举报

candela4rk

注册会员

积分
91
15#
 楼主| 发表于 2020-5-19 17:41:00 | 只看该作者
jefferyzhang 发表于 2020-5-19 17:33
从你lsusb结果来看都是正常的。
请问下你的开发版是谁家的,型号是什么,系统是什么,是3399pro还是1808计 ...

产品名称:TB-RK3399ProDs
产品型号:T331040232D
系统: Debian10
回复

使用道具 举报

candela4rk

注册会员

积分
91
16#
 楼主| 发表于 2020-5-19 17:44:41 | 只看该作者
jefferyzhang 发表于 2020-5-19 17:33
从你lsusb结果来看都是正常的。
请问下你的开发版是谁家的,型号是什么,系统是什么,是3399pro还是1808计 ...
  1. #include <stdio.h>
  2. #include "rknn_api.h"
  3. #include <pthread.h>
  4. #include <fstream>

  5. int main()
  6. {
  7.    rknn_context ctx = 0;
  8.    const char *model_path = "/home/toybrick/rknn_api/mobilenet_ssd.rknn";
  9.    FILE *fp = fopen(model_path, "rb");
  10.     if(fp == NULL) {
  11.         printf("fopen %s fail!\n", model_path);
  12.         return -1;
  13.     }
  14.     fseek(fp, 0, SEEK_END);
  15.     int model_len = ftell(fp);
  16.     void *model = malloc(model_len);
  17.     fseek(fp, 0, SEEK_SET);
  18.     if(model_len != fread(model, 1, model_len, fp)) {
  19.         printf("fread %s fail!\n", model_path);
  20.         free(model);
  21.         return -1;
  22.     }
  23.    rknn_init(&ctx, model, model_len, RKNN_FLAG_PRIOR_MEDIUM);
  24.    rknn_sdk_version version;
  25.    rknn_query(ctx, RKNN_QUERY_SDK_VERSION, &version, sizeof(rknn_sdk_version));
  26.    printf("api version: %s\n", version.api_version);
  27.    printf("driver version: %s\n", version.drv_version);
  28.     rknn_devices_id devids;
  29.     rknn_find_devices(&devids);
  30.     printf("n_devices = %d\n", devids.n_devices);
  31.     for (int i = 0; i < devids.n_devices; i++)
  32.     {
  33.         printf("%d: type=%s, id=%s\n", i, devids.types[i], devids.ids[i]);
  34.     }
  35.     return 0;
  36. }
复制代码

输出:
E RKNNAPI: rknn_init,  driver open fail!  ret = -9(ERROR_PIPE)!
E RKNNAPI: rknn_query,  context = nullptr!
api version:
driver version: �m��
E RKNNAPI: rknn_find_devices fail!
n_devices = 0
回复

使用道具 举报

addy

超级版主

积分
609
17#
发表于 2020-5-19 18:27:27 | 只看该作者
执行命令:npu_transfer_devices
确认下设备是否存在。
回复

使用道具 举报

candela4rk

注册会员

积分
91
18#
 楼主| 发表于 2020-5-20 10:12:19 | 只看该作者
addy 发表于 2020-5-19 18:27
执行命令:npu_transfer_devices
确认下设备是否存在。

我更新驱动以后,npu_transfer_proxy devices输出:
List of ntb devices attached
9cd15daa2683fa8f    2c41d4f0    USB_DEVICE

C++代码输出:
D RKNNAPI: ==============================================
D RKNNAPI: RKNN VERSION:
D RKNNAPI:   API: 1.3.0 (c5654ea build: 2019-12-25 14:12:00)
D RKNNAPI:   DRV: 1.3.1 (6ebb4d7 build: 2020-01-02 09:37:58)
D RKNNAPI: ==============================================
api version: 1.3.0 (c5654ea build: 2019-12-25 14:12:00)
driver version: 1.3.1 (6ebb4d7 build: 2020-01-02 09:37:58)
n_devices = 1
0: type=USB_DEVICE, id=9cd15daa2683fa8f

wiki的推理程序报错:
-->loading model
loading model done
--> Init runtime environment
E Only support ntb mode on ARM64 platform. But can not find device with ntb mode.
E Catch exception when init runtime!
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 1042, in rknn.api.rknn_base.RKNNBase.init_runtime
E   File "rknn/api/rknn_runtime.py", line 168, in rknn.api.rknn_runtime.RKNNRuntime.__init__
E   File "rknn/api/rknn_platform_utils.py", line 285, in rknn.api.rknn_platform_utils.start_ntp_or_adb
E Exception: Init runtime environment failed!
E Current device id is: 9cd15daa2683fa8f
E Devices connected:
E ['9cd15daa2683fa8f']
Init runtime environment failed
回复

使用道具 举报

candela4rk

注册会员

积分
91
19#
 楼主| 发表于 2020-5-20 10:30:48 | 只看该作者
jefferyzhang 发表于 2020-5-19 17:33
从你lsusb结果来看都是正常的。
请问下你的开发版是谁家的,型号是什么,系统是什么,是3399pro还是1808计 ...

回到开始的问题了,模型转换也出错了:
--> Loading model
W:tensorflow:From /home/toybrick/.local/lib/python3.7/site-packages/onnx_tf/handlers/backend/ceil.py:10: The name tf.ceil is deprecated. Please use tf.math.ceil instead.

W:tensorflow:From /home/toybrick/.local/lib/python3.7/site-packages/onnx_tf/handlers/backend/depth_to_space.py:12: The name tf.depth_to_space is deprecated. Please use tf.compat.v1.depth_to_space instead.

W:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/co ... 7-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

W:tensorflow:From /home/toybrick/.local/lib/python3.7/site-packages/onnx_tf/handlers/backend/log.py:10: The name tf.log is deprecated. Please use tf.math.log instead.

W:tensorflow:From /home/toybrick/.local/lib/python3.7/site-packages/onnx_tf/handlers/backend/random_normal.py:9: The name tf.random_normal is deprecated. Please use tf.random.normal instead.

W:tensorflow:From /home/toybrick/.local/lib/python3.7/site-packages/onnx_tf/handlers/backend/random_uniform.py:9: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.

W:tensorflow:From /home/toybrick/.local/lib/python3.7/site-packages/onnx_tf/handlers/backend/upsample.py:13: The name tf.image.resize_images is deprecated. Please use tf.image.resize instead.

/home/toybrick/.local/lib/python3.7/site-packages/onnx_tf/common/__init__.py:87: UserWarning: FrontendHandler.get_outputs_names is deprecated. It will be removed in future release.. Use node.outputs instead.
  warnings.warn(message)
W:tensorflow:From /home/toybrick/.local/lib/python3.7/site-packages/rknn/api/rknn.py:67: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
E Catch exception when loading tensorflow model: tiny-yolo-voc.pb!
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 215, in rknn.api.rknn_base.RKNNBase.load_tensorflow
E   File "rknn/base/RKNNlib/converter/convert_tf.py", line 527, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.pre_process
E   File "rknn/base/RKNNlib/converter/tensorflowloader.py", line 96, in rknn.base.RKNNlib.converter.tensorflowloader.TF_Graph_Preprocess.pre_proces
E   File "rknn/base/RKNNlib/converter/tensorflowloader.py", line 555, in rknn.base.RKNNlib.converter.tensorflowloader.TF_Graph_Preprocess.import_tf_ruler_module
E   File "/home/toybrick/.local/lib/python3.7/site-packages/rknn/base/RKNNlib/converter/tfruler/__init__.py", line 2, in <module>
E     from .tf_ruler_generate import r_add_n_template, r_concatv2_template, r_split_template
E ImportError: cannot import name 'r_add_n_template' from 'tfruler.tf_ruler_generate' (/home/toybrick/.local/lib/python3.7/site-packages/rknn/base/RKNNlib/converter/tfruler/tf_ruler_generate.cpython-37m-aarch64-linux-gnu.so)
done
--> Building model
Traceback (most recent call last):
  File "ex.py", line 32, in <module>
    rknn.build(do_quantization=False)
  File "/home/toybrick/.local/lib/python3.7/site-packages/rknn/api/rknn.py", line 222, in build
    inputs = self.rknn_base.net.get_input_layers()
AttributeError: 'NoneType' object has no attribute 'get_input_layers'
回复

使用道具 举报

jefferyzhang

版主

积分
13578
20#
发表于 2020-5-20 10:54:09 | 只看该作者
E     from .tf_ruler_generate import r_add_n_template, r_concatv2_template, r_split_template
E ImportError: cannot import name 'r_add_n_template' from 'tfruler.tf_ruler_generate' (/home/toybrick/.local/lib/python3.7/site-packages/rknn/base/RKNNlib/converter/tfruler/tf_ruler_generate.cpython-37m-aarch64-linux-gnu.so)

这个应该是某个op不支持
回复

使用道具 举报

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

本版积分规则

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


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