Toybrick

1808计算棒只能调用一次,第二次就卡在--> Init runtime environm...

cyberdong

新手上路

积分
48
楼主
发表于 2021-9-21 11:01:04    查看: 5051|回复: 6 | [复制链接]    打印 | 只看该作者
在Win10下运行rknn-toolkit自带的tflite/mobilenet_v1的例子(修改了代码,不是在模拟器运行,是在1808计算棒的NPU上运行)。
第一次可以正确运行,下面是部分结果:
--> Init runtime environment
D RKNNAPI: ==============================================
D RKNNAPI: RKNN VERSION:
D RKNNAPI:   API: 1.7.0 (f75fb8e build: 2021-07-21 09:06:12)
D RKNNAPI:   DRV: 1.6.0 (159d2d3 build: 2021-01-12 15:23:09)
D RKNNAPI: ==============================================
done
--> Running model
mobilenet_v1
-----TOP 5-----
[156]: 0.85107421875
[155]: 0.09173583984375
[205]: 0.01358795166015625
[284]: 0.006465911865234375
[194]: 0.002239227294921875

done

第二次再运行python test.py,就卡在--> Init runtime environment就不动了。。。
Use tf.where in 2.0, which has the same broadcast rule as np.where
done
--> Export RKNN model
done
--> Init runtime environment


回复

使用道具 举报

jefferyzhang

版主

积分
13572
沙发
发表于 2021-9-21 11:05:04 | 只看该作者
这个可能是API和DRV版本不匹配造成的,退出时候DRV那边可能并没有匹配到正确的退出指令。
你可以试试用API1.6.0来跑你的模型,如果转换没问题的话尽量保持两个版本匹配
回复

使用道具 举报

cyberdong

新手上路

积分
48
板凳
 楼主| 发表于 2021-9-21 11:07:28 | 只看该作者
第二次运行的完整log:

python test.py
--> config model
done
--> Loading model
W:tensorflow:From C:\Users\Test\AppData\Roaming\Python\Python36\site-packages\rknn\api\rknn.py:106: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

W:tensorflow:From C:\Users\Test\AppData\Roaming\Python\Python36\site-packages\rknn\api\rknn.py:106: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W:tensorflow:From C:\Users\Test\AppData\Roaming\Python\Python36\site-packages\rknn\api\rknn.py:106: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

done
--> Building model
W The target_platform is not set in config, using default target platform rk1808.
W:tensorflow:From C:\Users\Test\AppData\Roaming\Python\Python36\site-packages\rknn\api\rknn.py:257: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

W:tensorflow:From C:\Users\Test\AppData\Roaming\Python\Python36\site-packages\rknn\api\rknn.py:257: The name tf.FIFOQueue is deprecated. Please use tf.queue.FIFOQueue instead.

W:tensorflow:From C:\Users\Test\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\ops\control_flow_ops.py:1814: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version.
Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, there are two
    options available in V2.
    - tf.py_function takes a python function which manipulates tf eager
    tensors instead of numpy arrays. It's easy to convert a tf eager tensor to
    an ndarray (just call tensor.numpy()) but having access to eager tensors
    means `tf.py_function`s can use accelerators such as GPUs as well as
    being differentiable using a gradient tape.
    - tf.numpy_function maintains the semantics of the deprecated tf.py_func
    (it is not differentiable, and manipulates numpy arrays). It drops the
    stateful argument making all functions stateful.

W:tensorflow:From C:\Users\Test\AppData\Roaming\Python\Python36\site-packages\rknn\api\rknn.py:257: The name tf.nn.avg_pool is deprecated. Please use tf.nn.avg_pool2d instead.

W:tensorflow:From C:\Users\Test\AppData\Roaming\Python\Python36\site-packages\rknn\api\rknn.py:257: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
done
--> Export RKNN model
done
--> Init runtime environment
回复

使用道具 举报

cyberdong

新手上路

积分
48
地板
 楼主| 发表于 2021-9-21 13:18:54 | 只看该作者
等了好久,终于出现了错误信息:

--> Init runtime environment
E RKNNAPI: rknn_init,  recv(MsgLoadAck) fail, -9 != 368!
E Catch exception when init runtime!
E Traceback (most recent call last):
E   File "rknn\api\rknn_base.py", line 884, in rknn.api.rknn_base.RKNNBase.init_runtime
E   File "rknn\api\rknn_runtime.py", line 341, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
E Exception: RKNN init failed. error code: RKNN_ERR_DEVICE_UNAVAILABLE
E Current device id is: None
E Devices connected:
E ['TS018083200400200']
Init runtime environment failed
回复

使用道具 举报

cyberdong

新手上路

积分
48
5#
 楼主| 发表于 2021-9-21 15:59:02 | 只看该作者
jefferyzhang 发表于 2021-9-21 11:05
这个可能是API和DRV版本不匹配造成的,退出时候DRV那边可能并没有匹配到正确的退出指令。
你可以试试用API1 ...

换成rknn-toolkit 1.6.0的版本,还是一样的现象。

另外,如何获取device ID呢?下面这个命令的输出跟文档不一样,没有显示Device ID
W:\workspace\mobilenet_v1
λ python -m rknn.bin.list_devices
*************************
all device(s) with ntb mode:
TS018083200400200
*************************
回复

使用道具 举报

cyberdong

新手上路

积分
48
6#
 楼主| 发表于 2021-9-21 16:05:19 | 只看该作者
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from rknn.api import RKNN
>>> rknn=RKNN()
>>> rknn.list_devices()
*************************
all device(s) with ntb mode:
TS018083200400200
*************************
([], ['TS018083200400200'])  -- 这个就是Device ID吗?
>>> rknn.release()
回复

使用道具 举报

cyberdong

新手上路

积分
48
7#
 楼主| 发表于 2021-9-21 16:14:10 | 只看该作者
卡在这个地方了:
--> Init runtime environment
D target set by user is: rk1808
D Starting ntp or adb, target is RK1808, host is None
D Start ntp...
I npu_transfer_proxy pid: 10704, status: running
回复

使用道具 举报

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

本版积分规则

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


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