Toybrick

标题: 1808计算棒只能调用一次,第二次就卡在--> Init runtime environm... [打印本页]

作者: cyberdong    时间: 2021-9-21 11:01
标题: 1808计算棒只能调用一次,第二次就卡在--> Init runtime environm...
在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    时间: 2021-9-21 11:05
这个可能是API和DRV版本不匹配造成的,退出时候DRV那边可能并没有匹配到正确的退出指令。
你可以试试用API1.6.0来跑你的模型,如果转换没问题的话尽量保持两个版本匹配
作者: cyberdong    时间: 2021-9-21 11:07
第二次运行的完整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    时间: 2021-9-21 13:18
等了好久,终于出现了错误信息:

--> 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    时间: 2021-9-21 15:59
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    时间: 2021-9-21 16:05
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    时间: 2021-9-21 16:14
卡在这个地方了:
--> 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




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