首页 > 解决方案 > 构建 TF micro hello world: make: *** [tensorflow/lite/micro/examples/hello_world/Makefile.inc:34: test_hello_world_test] 错误 1

问题描述

我正在关注 Pete Warden 和 Daniel Situnayake 的 TinyML 书,内容是关于如何使用 TFLite 将神经网络部署到微控制器上。他们严格遵循此 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

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

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

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

标签: c++tensorflowmakefilegnu-maketensorflow-lite

解决方案


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

第一步是前往你刚刚克隆的 git repo 的根目录。然后,不要test_在 make 上将前缀添加到目标,只需将其“制作”为“普通目标”:

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

根据您正在运行的操作系统,可执行文件(输出)将位于不同的路径中,但只需windows_x86_64将对应的文件夹。现在是时候运行输出了:

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

正如预期的那样返回:

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

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

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


推荐阅读