nnabla-c-runtime icon indicating copy to clipboard operation
nnabla-c-runtime copied to clipboard

nnabla_cli converstion to output.nnb cannot be loaded on Spresense board

Open entrpn opened this issue 6 years ago • 4 comments

I am trying to use a trained model on a Sony Spresense board, however after training and converting my nnp file to nnb, the Spresense board cannot load the file. Following this example:

https://github.com/sony/nnabla-examples/tree/master/mnist-collection

The command I used to convert the nnp to nnb file:

nnabla_cli convert input.nnp output.nnb

Using the Arduino IDE, I loaded this example https://github.com/sonydevworld/spresense-arduino-compatible/blob/master/Arduino15/packages/SPRESENSE/hardware/spresense/1.0.0/libraries/DNNRT/examples/number_recognition/number_recognition.ino

Using the following library:

#include <DNNRT.h>

But the program gets stuck in this line

int ret = dnnrt.begin(nnbfile);

If I train using the Sony cloud https://dl.sony.com, the nnb file works fine with the Spresense board. Is there something I'm doing wrong? Thanks!

entrpn avatar Dec 28 '18 20:12 entrpn

I have no SPRESENSE on hand, so I cannot now make sure
my idea is the direct solution against your issue.
I imagine your issue is because NNB supports minibatch inference.
What is confusing is, probably, the default bath size is not 1 in nnabla_cli. Thus, could you try the following command?

nnabla_cli convert -b 1 input.nnp output.nnb

I'm sorry if my idea is not enough to help you :(

ghost avatar Jan 04 '19 07:01 ghost

Thank you for your reply. Unfortunately it didn't work.

I also tried the following but didn't work as well.

nnabla_cli convert -I NNP -O NNB -b 1 resnet_result.nnp output.nnb

If you are able to access the build process of https://dl.sony.com/, then taking a look at how the nnb file is created could give me a clue since exporting an nnb file from there works on the Spresense board. Thanks!

entrpn avatar Jan 05 '19 23:01 entrpn

instead of nnabla_cli convert -b 1 input.nnp output.nnb, do nnabla_cli convert -b 1 --api 1 input.nnp output.nnb This output.nnb will work in spresense

prajotsl123 avatar Oct 13 '21 09:10 prajotsl123

Thank you for providing valuable information!

When spresense was introduced, nnabla's api level was 1, so it only -b 1 option worked fine. But we updated api level to add more functions, so we have needed to add --api option when converting. Sorry for missing information.

TomonobuTsujikawa avatar Oct 19 '21 01:10 TomonobuTsujikawa