Spresense SDK - Tensorflow : Flatbuffers missing



  • Hello I am trying to recreate Tensorflow demo called :"micro_speech" located : "tensorflow/lite/micro/examples/micro_speech/"

    However during a build I am getting : "fatal error: flatbuffers/flatbuffers.h: No such file or directory"

    I really don't know how to solve this issue?
    Is there anyway how to import this library ?


  • DeveloperWorld

    Hi @Arco

    The flatbuffers library is downloaded during the build process. Please check if you successfully downloaded the flatbuffers library while building. You can check this in the logs after running make command.

    After a successful download, the library will be here: externals/tensorflow/tensorflow-<SHA1>/tensorflow/lite/micro/tools/make/downloads/flatbuffers

    Best Regards,
    Kamil Tomaszewski



  • Hello @KamilTomaszewski

    Thank you very much for your help.

    Yes the flatbuffers library was missing, unfortunately I was not able to run make command so I manually launched flatbuffers_download.sh script which successfully downloaded this library. However problem still persists 😞

    Thanks, Juraj



  • Here is messages :

    In file included from /Users/arcius/spresenseenv/usr/arm-none-eabi/include/c++/7.3.1/type_traits:35:0,
                     from /Users/arcius/C++/Sony-Spresense/spresense/sdk/../externals/tensorflow/tensorflow-372e7eef27e03adabceb4c7ca41d366776573a73/tensorflow/lite/core/api/flatbuffer_conversions.h:24,
                     from /Users/arcius/C++/Sony-Spresense/spresense/sdk/../externals/tensorflow/tensorflow-372e7eef27e03adabceb4c7ca41d366776573a73/tensorflow/lite/micro/micro_mutable_op_resolver.h:23,
                     from /Users/arcius/C++/Sony-Spresense/spresense/sdk/../externals/tensorflow/tensorflow-372e7eef27e03adabceb4c7ca41d366776573a73/tensorflow/lite/micro/all_ops_resolver.h:19,
                     from VoiceRecognition.cxx:3:
    /Users/arcius/spresenseenv/usr/arm-none-eabi/include/c++/7.3.1/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
     #error This file requires compiler and library support \
      ^~~~~
    In file included from /Users/arcius/C++/Sony-Spresense/spresense/sdk/../externals/tensorflow/tensorflow-372e7eef27e03adabceb4c7ca41d366776573a73/tensorflow/lite/core/api/flatbuffer_conversions.h:28:0,
                     from /Users/arcius/C++/Sony-Spresense/spresense/sdk/../externals/tensorflow/tensorflow-372e7eef27e03adabceb4c7ca41d366776573a73/tensorflow/lite/micro/micro_mutable_op_resolver.h:23,
                     from /Users/arcius/C++/Sony-Spresense/spresense/sdk/../externals/tensorflow/tensorflow-372e7eef27e03adabceb4c7ca41d366776573a73/tensorflow/lite/micro/all_ops_resolver.h:19,
                     from VoiceRecognition.cxx:3:
    /Users/arcius/C++/Sony-Spresense/spresense/sdk/../externals/tensorflow/tensorflow-372e7eef27e03adabceb4c7ca41d366776573a73/tensorflow/lite/schema/schema_generated.h:21:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
     #include "flatbuffers/flatbuffers.h"
    

  • DeveloperWorld

    Hi @Arco

    What OS are you using?



  • @KamilTomaszewski

    BigSur ( Macbook M1 )


  • DeveloperWorld

    @Arco

    I think the problem may be that TensorFlow doesn't support building on Mac.

    Could you please try to build this example on any target: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/micro/examples/hello_world
    Follow the instructions from the README.



  • @KamilTomaszewski

    I can see ( from build logs ) that tensorflow sources are build successfully. The output builds can be found in

    /spresense/externals/tensorflow/tensorflow-372e7eef27e03adabceb4c7ca41d366776573a73/tensorflow/lite/micro/tools/make/gen/spresense_cortex-m4_micro
    

    however when use this includes in my project :

    #include "tensorflow/lite/micro/all_ops_resolver.h"
    #include "tensorflow/lite/micro/micro_error_reporter.h"
    #include "tensorflow/lite/micro/micro_interpreter.h"
    #include "tensorflow/lite/schema/schema_generated.h"
    #include "tensorflow/lite/version.h"
    

    I am getting error mentioned above.

    In SDK Config I set 'Spresense SDK' -> 'Externals' -> 'Tensorflow lite micro' to 'Y'.

    Also in Makefile of my application ( command ) I set

    # C++ compiler flags
    CXXFLAGS = -std=c++11
    

    To avoid those

    error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
    #error This file requires compiler and library support \
    

    Is there anything that I forgot ? ( I don't think that problem is with TensorFlow and Mac ).

    Thanks


  • DeveloperWorld

    @Arco

    Since you are trying to recreate Tensorflow demo called :"micro_speech", can you try to run these commands:

    spresense/sdk$ make distclean
    spresense/sdk$ ./tools/config.py examples/tf_example_micro_speech
    spresense/sdk$ make
    

    This will allow you to build and run "micro_speech" demo on Spresense. Flash .spk, open nuttx shell and run this command:

    nsh> tf_example
    

    I would like to first check if you can successfully run it. Please let me know.



  • @KamilTomaszewski

    tf_example_micro_speech was successfully build -> flashed -> launched ( working correctly ) on my Spresense.


  • DeveloperWorld

    @Arco Thank you for your confirmation.

    The problem is that the compiler doesn't have the path given where the flatbuffers library is. Even if you add it, you will encounter other errors. This is because there are two build systems. The first is NuttX which has its own implementations of standard libraries. The second is TensorFlow which uses the standard libraries from the compiler. When you try to build something with TensorFlow on NuttX then you have compatibility problems with standard libraries.

    If you want to create a new application then you must include it in the TensorFlow system build. Then, in the NuttX application, call functions like in this example:
    https://github.com/sonydevworld/spresense/blob/master/examples/tf_example

    It is currently not possible to call TensorFlow functions directly from the NuttX application. This is only temporary because we are working to make it possible. This is the first SDK release that has allowed the TensorFlow examples to run on Spresense and unfortunately has some limitations.

    I am sorry for the inconvenience.
    Best Regards,
    Kamil Tomaszewski



  • @KamilTomaszewski Thank for your help I own you one 🙂

    Do you think that another solutions like CircuitPython or MicroEJ would be better for using TensorFlow ?

    Thank you again


  • DeveloperWorld

    @Arco You're welcome. 🙂

    Unfortunately, TensorFlow is currently only supported on the NuttX SDK.


Log in to reply