SaveModelBundle в TensorFlow генерирует ошибку

#c #tensorflow #tensorflow2.0 #tensorflow-serving

#c #tensorflow #tensorflow2.0 #tensorflow-обслуживание

Вопрос:

Почему tensorflow::SaveModelBundle вызывает ошибку? Чего мне не хватает в следующем коде? Когда я комментирую строку «tensorflow::SavedModelBundle bundle;», тогда проблем нет.

 #include <fstream>
#include <utility>
#include <vector>

#include"google/protobuf/message.h"
#include "tensorflow/cc/ops/const_op.h"
#include "tensorflow/cc/ops/image_ops.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/cc/saved_model/loader.h"//savedmodelbundle
#include "tensorflow/cc/saved_model/constants.h"
#include "tensorflow/cc/saved_model/signature_constants.h"
#include "tensorflow/cc/saved_model/tag_constants.h"// kSavedModelTagServe
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/graph/default_device.h"
#include "tensorflow/core/graph/graph_def_builder.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/core/threadpool.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/init_main.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/public/session.h"
#include "tensorflow/core/util/command_line_flags.h"

using tensorflow::Flag;
using tensorflow::int32;
using tensorflow::Status;
using tensorflow::string;
using tensorflow::Tensor;
using tensorflow::tstring;
using namespace tensorflow;

int main(int argc, char* argv[]) {

  tensorflow::SavedModelBundle bundle;

  tensorflow::SessionOptions session_options;
  tensorflow::RunOptions run_options;
  tensorflow::Status status;

  return 0;
}
  

Я получаю следующую ошибку в Ubuntu 18.04, используя TensorFlow 2.3 (C API).

 CMakeFiles/example.dir/exam.cpp.o: In function `google::protobuf::internal::MapField<tensorflow::MetaGraphDef_SignatureDefEntry_DoNotUse, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, tensorflow::SignatureDef, (google::protobuf::internal::WireFormatLite::FieldType)9, (google::protobuf::internal::WireFormatLite::FieldType)11, 0>::GetMap() const':
exam.cpp:(.text._ZNK6google8protobuf8internal8MapFieldIN10tensorflow39MetaGraphDef_SignatureDefEntry_DoNotUseENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS3_12SignatureDefELNS1_14WireFormatLite9FieldTypeE9ELSD_11ELi0EE6GetMapEv[_ZNK6google8protobuf8internal8MapFieldIN10tensorflow39MetaGraphDef_SignatureDefEntry_DoNotUseENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS3_12SignatureDefELNS1_14WireFormatLite9FieldTypeE9ELSD_11ELi0EE6GetMapEv] 0x14): undefined reference to `google::protobuf::internal::MapFieldBase::SyncMapWithRepeatedField() const'
collect2: error: ld returned 1 exit status
CMakeFiles/example.dir/build.make:95: recipe for target 'example' failed
make[2]: *** [example] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/example.dir/all' failed
make[1]: *** [CMakeFiles/example.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
  

Комментарии:

1. Здесь та же проблема, используя удобный образ docker из: github.com/FloopCZ/tensorflow_cc

2. Я также сталкиваюсь с той же ошибкой. Не могли бы вы опубликовать решение? Как вы это решили.

3. Я не смог ее решить. Но я предполагаю, что SavedModelBundle предназначен для замороженного графика, который не поддерживается в последних версиях TensorFlow.