问题描述
我正在关注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起作用)时,它仍会打印该消息。
我尝试寻找类似的问题,但没有任何效果。这是有关我的PC的一些信息:
- Windows 10家庭版64位
- GNU Make 4.3
- gcc.exe(Rev5,由MSYS2项目构建)5.3.0
- 已安装Conda
- 控制台:Git Bash(MINGW64)
-
$make
和$gcc
都在PATH中
如果您需要更多信息,请告诉我。
解决方法
我仍然必须在github上打开一个问题,因为我认为这不是预期的行为,但是这是一种变通方法,可让您在开发机器上测试TF微代码。
第一步是转到刚刚克隆的git repo的根目录。然后,不要在make的目标上添加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生成测试文件后似乎无法执行它,因此解决方案是分不同的步骤进行。
请记住您需要使版本3.82或更高版本有效。如果您使用Windows。您可以使用Git Bash控制台并通过chocolatey安装最新版本的Make。