构建TF micro hello world: make: *** [tensorflow/lite/micro/examples/hello_world/Makefile.inc:34: test_hello_world_test] 错误1

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

我正在关注 Pete Warden 和 Daniel Situnayake 的 TinyML 书,内容是关于如何使用适用于微控制器的 TFLite 将神经网络部署到微控制器。他们严格按照 this git repo.

末尾的说明进行操作

为了尝试检查错误,他们建议在开发机器(即我的 PC)上测试代码,但是当 运行“make”时,我遇到了一些错误并且无法构建。

当运行 $ git clone --depth 1 https://github.com/tensorflow/tensorflow.git 然后 $ make -f tensorflow/lite/micro/tools/make/Makefile test_hello_world_test 我得到以下输出:

$ 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

尽管它说“所有测试都已通过”,但由于错误而没有构建;当更改源文件以引入一些错误(以检查 evcerything 是否正常工作)时,它仍然会打印该消息。

我尝试寻找类似的问题,但没有任何效果。这是关于我的电脑的一些信息:

如果您需要更多信息,请告诉我,谢谢。

我仍然需要在 github 上打开一个问题,因为我认为这不是预期的行为,但这里有一个解决方法,允许您在开发机器上测试您的 TF 微代码。

第一步是前往您刚刚克隆的 git 存储库的根目录。然后,不是在 make 上给目标添加 test_ 前缀,而是将其“制作”为“普通目标”:

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

根据您正在 运行 的 OS,可执行文件(输出)将位于不同的路径中,但只需将 windows_x86_64 更改为相应的文件夹即可。现在是 运行 输出的时候了:

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

这returns,如预期:

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

我已经用不同的组合和项目对其进行了测试,它工作得很好。似乎 Make 在生成测试文件后无法执行它,因此解决方案是分步执行。

请记住,您需要 Make 版本 3.82 或更高版本才能正常工作。如果您使用 Windows。您可以使用 Git Bash 控制台并通过 chocolatey.

安装最新版本的 Make