C++ Tensorflow lite,某些函数的引用未定义

2uluyalo  于 2023-02-01  发布在  其他
关注(0)|答案(1)|浏览(183)

我尝试在我的debian 11 intel x86_64架构上使用tensorflow lite来构建和运行一个项目,到目前为止我已经按照官方文档和官方github example运行了。
以下是我遵循的步骤:
1.在~/桌面/上运行了git clone https://github.com/tensorflow/tensorflow.git tensorflow_src

  1. x1米1米1和x1米2米1
  2. cmake ../tensorflow_src/tensorflow/lite
  3. cmake --build .我已经删除了-J标志,不管文档怎么说,因为它会导致我的电脑冻结。
  4. mkdir ~/Desktop/tf_testcd ~/Desktop/tf_test
    1.在tf_test目录中创建一个CMakeLists.txt和一个main.cpp文件。
    1.将最小示例中的主要代码放在上面提供的github repo中,然后将以下代码放在CMake中:
cmake_minimum_required(VERSION 3.16)
project(minimal C CXX)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTFLITE_DISABLE_TELEMETRY=1")

set(TENSORFLOW_SOURCE_DIR "" CACHE PATH
  "Directory that contains the TensorFlow project" )
if(NOT TENSORFLOW_SOURCE_DIR)
  get_filename_component(TENSORFLOW_SOURCE_DIR
    "/home/user/Desktop/tensorflow_src" ABSOLUTE)
endif()

add_subdirectory(
  "${TENSORFLOW_SOURCE_DIR}/tensorflow/lite"
  "${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite" EXCLUDE_FROM_ALL)

add_executable(minimal minimal.cc)
target_link_libraries(minimal tensorflow-lite)

1.创建文件夹tf_Test/build并在其中运行cmake ..

  1. cmake完成后,我在build目录中运行make,并收到以下错误:
...
[100%] Linking CXX executable minimal
/usr/bin/ld: tensorflow-lite/libtensorflow-lite.a(interpreter.cc.o): in function `tflite::impl::Interpreter::ReportTelemetrySettings(char const*)':
interpreter.cc:(.text+0x292f): undefined reference to `tflite::telemetry::TelemetryReportSettings(TfLiteContext*, char const*, TfLiteTelemetryInterpreterSettings const*)'
/usr/bin/ld: tensorflow-lite/libtensorflow-lite.a(subgraph.cc.o): in function `tflite::Subgraph::Invoke()':
subgraph.cc:(.text+0x41c0): undefined reference to `tflite::telemetry::TelemetryReportEvent(TfLiteContext*, char const*, TfLiteStatus)'
/usr/bin/ld: tensorflow-lite/libtensorflow-lite.a(subgraph.cc.o): in function `tflite::Subgraph::ModifyGraphWithDelegate(TfLiteDelegate*)':
subgraph.cc:(.text+0x6ad0): undefined reference to `tflite::telemetry::TelemetryReportEvent(TfLiteContext*, char const*, TfLiteStatus)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/minimal.dir/build.make:184: minimal] Error 1
make[1]: *** [CMakeFiles/Makefile2:1408: CMakeFiles/minimal.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

注意并不是所有的函数都是这样的,例如std::unique_ptr<tflite::FlatBufferModel> model = tflite::FlatBufferModel::BuildFromFile(filename);可以正常工作。
这些树正在制造麻烦:tflite::ops::builtin::BuiltinOpResolver resolver; std::unique_ptr<tflite::Interpreter> interpreter; tflite::InterpreterBuilder(*model, resolver)(&interpreter);
注意:为了测试的目的,我在github示例中删减了一些代码,所以只有上面的4行代码出现在我的main中。
为什么我会得到这个错误?我也试过用bazel编译,但是我得到了同样的错误。我错过了什么?

kxe2p93d

kxe2p93d1#

CMakeLists文件中可能缺少该文件
更新CMakeLists.txt并将tensorflow /lite/剖面/遥测/telemetry.cc和tensorflow /lite/剖面/遥测/遥测. h添加到TFLITE_PROFILER_SRCS
还值得为团队创建Tensorflow repo问题

相关问题