Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking protobuf issue in Docker images with saved model #267

Closed
bogdanteleaga opened this issue Jun 11, 2021 · 3 comments · Fixed by #246
Closed

Linking protobuf issue in Docker images with saved model #267

bogdanteleaga opened this issue Jun 11, 2021 · 3 comments · Fixed by #246

Comments

@bogdanteleaga
Copy link

This issue seems to come up a lot, especially with local builds, but it seems to happen also within the Docker images provided. A simple program like

#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/public/session.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/cc/saved_model/loader.h"
#include "tensorflow/cc/saved_model/tag_constants.h"

using namespace tensorflow;

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

    auto export_dir = "dir";
    // Load
    SavedModelBundleLite model_bundle;
    SessionOptions session_options = SessionOptions();
    RunOptions run_options = RunOptions();
    Status status = LoadSavedModel(session_options, run_options, export_dir, {kSavedModelTagServe}, &model_bundle);

    // Inference
    const std::vector<string> outputLayer = {"Identity:0"};
    tensorflow::Tensor input_tensor(DT_COMPLEX64, TensorShape({1, 512, 1536, 2}));
    std::vector<tensorflow::Tensor> outputs;
    Status runStatus = model_bundle.GetSession()->Run({{"input:0", input_tensor}}, outputLayer, {}, &outputs);
}

Cannot be linked and results in lots of protobuf errors similar to

/usr/bin/ld: CMakeFiles/example.dir/example.o: in function `google::protobuf::Map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, tensorflow::SignatureDef>::Init()':
example.cpp:(.text._ZN6google8protobuf3MapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN10tensorflow12SignatureDefEE4InitEv[_ZN6google8protobuf3MapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN10tensorflow12SignatureDefEE4InitEv]+0x2ea): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'

This is using the floopcz/tensorflow_cc:ubuntu image.

@FloopCZ
Copy link
Owner

FloopCZ commented Jun 13, 2021

Yes yes, that is an annoying issue. One solution could be to detect and add the protobuf version that bazel uses as an external dependency as mentioned by @cweigel in #246. Unfortunately, I have not made any attempts to do that yet, if anyone is interested, I would surely accept a PR. 🙂

@FloopCZ FloopCZ linked a pull request Jun 13, 2021 that will close this issue
@isra60
Copy link

isra60 commented Sep 9, 2021

Hi, are there any updates on this? I found the same problem using the ubuntu-Cuda docker version

@lancelot-ch
Copy link

lancelot-ch commented May 11, 2022

I can compile these codes using tensorflow_cc with no errors. However, I am using a fork:
https://github.com/mrdaliri/tensorflow_cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants