Search code examples
c++tensorflowmakefilegnu-maketensorflow-lite

Building TF micro hello world: make: *** [tensorflow/lite/micro/examples/hello_world/Makefile.inc:34: test_hello_world_test] Error 1


I am following the TinyML book by Pete Warden and Daniel Situnayake on how to deploy neural networks to microcontrollers with TFLite for microcontrollers. They closely follow the instructions at the end of this git repo.

To try and check for errors, they propose testing the code on the development machine(i.e my PC), but when running "make" I get some errors and it does not build.

When running $ git clone --depth 1 https://github.com/tensorflow/tensorflow.git and then $ make -f tensorflow/lite/micro/tools/make/Makefile test_hello_world_test I get the following output:

$ make -f tensorflow/lite/micro/tools/make/Makefile test_hello_world_test
tensorflow/lite/micro/tools/make/Makefile:305: warning: overriding recipe for target 'tensorflow/lite/micro/tools/make/downloads/ruy'
tensorflow/lite/micro/tools/make/Makefile:305: warning: ignoring old recipe for target 'tensorflow/lite/micro/tools/make/downloads/ruy'
tensorflow/lite/micro/tools/make/Makefile:305: warning: overriding recipe for target 'tensorflow/lite/micro/tools/make/downloads/person_model_grayscale'
tensorflow/lite/micro/tools/make/Makefile:305: warning: ignoring old recipe for target 'tensorflow/lite/micro/tools/make/downloads/person_model_grayscale'
tensorflow/lite/micro/tools/make/Makefile:305: warning: overriding recipe for target 'tensorflow/lite/micro/tools/make/downloads/person_model_int8'
tensorflow/lite/micro/tools/make/Makefile:305: warning: ignoring old recipe for target 'tensorflow/lite/micro/tools/make/downloads/person_model_int8'
g++ -std=c++11 -DTF_LITE_STATIC_MEMORY -Werror -Wsign-compare -Wdouble-promotion -Wshadow -Wunused-variable -Wmissing-field-initializers -Wunused-function -DNDEBUG -O3 -I. -Itensorflow/lite/micro/tools/make/downloads/ -Itensorflow/lite/micro/tools/make/downloads/gemmlowp -Itensorflow/lite/micro/tools/make/downloads/flatbuffers/include -Itensorflow/lite/micro/tools/make/downloads/ruy -Itensorflow/lite/micro/tools/make/downloads/kissfft -o tensorflow/lite/micro/tools/make/gen/windows_x86_64/bin/hello_world_test tensorflow/lite/micro/tools/make/gen/windows_x86_64/obj/tensorflow/lite/micro/examples/hello_world/hello_world_test.o tensorflow/lite/micro/tools/make/gen/windows_x86_64/obj/tensorflow/lite/micro/examples/hello_world/model.o  tensorflow/lite/micro/tools/make/gen/windows_x86_64/lib/libtensorflow-microlite.a  -lm
tensorflow/lite/micro/testing/test_linux_binary.sh tensorflow/lite/micro/tools/make/gen/windows_x86_64/bin/hello_world_test '~~~ALL TESTS PASSED~~~'
make: *** [tensorflow/lite/micro/examples/hello_world/Makefile.inc:34: test_hello_world_test] Error 1

Although it says "All tests passed" it did not build due to the errors; when changing the source file to introduce some errors(to check evcerything works) it still prints that message.

I've tried looking for similar issues but nothing worked. Here is some info about my PC:

  • Windows 10 Home 64 bits
  • GNU Make 4.3
  • gcc.exe (Rev5, Built by MSYS2 project) 5.3.0
  • Conda is installed
  • Console: Git Bash (MINGW64)
  • Both $make and $gcc are in PATH

Please let me know if you need more information and thank you.


Solution

  • I still have to open an issue on github as I don't think this is the expected behavior but here is a workaround that allows you to test your TF micro code on your development machine.

    First step is heading to the root of the git repo you just cloned. Then, instead of adding the test_ prefix to the target on make, just "make" it as a "normal target":

    $ make -f tensorflow/lite/micro/tools/make/Makefile hello_world_test

    Depending on the OS you are running, the executable(output) will be in different paths, but just change the windows_x86_64 to your corresponding folder. Now it is time to run the output:

    $ tensorflow/lite/micro/tools/make/gen/windows_x86_64/bin/hello_world_test.exe

    This returns, as expected:

    Testing LoadModelAndPerformInference
    1/1 tests passed
    ~~~ALL TESTS PASSED~~~
    

    I've tested it with different combinations and projects and it works just fine. It seems like Make is having trouble executing the test file after generating it, so the solution was to do it in different steps.

    Remember you need Make version 3.82 or later for this to work. If you are using Windows. you can use the Git Bash console and install the latest version of Make via chocolatey.