crushiii
crushiii

Reputation: 1

C++ compiling project with shared object (libtensorflow_cc.so) failed

at the moment I'm facing some problems compiling (and running) a (huge) own project with support of Tensorflow. On my own system (Ubuntu 16.04 LTS) everything works fine. Same procedure on a cluster leads to a compile error and I'm not able to find a solution yet.

System information

Remark: On my own system it works this way for weeks now. I can use tensorflow in my own project with an exported model trained with keras inside a python project. I make predictions using client_sessions and many other functions of the tensorflow framework and it works properly.

Problem: At the cluster I can compile tensorflow as dynamic library, install protobuf and eigen. When I try to compile my project (similar process regarding my own system) without significant changes it doesn't work and stops with following error message:

.../tensorflow/include/tensorflow/core/framework/tensor.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
.../include/tensorflow/core/framework/tensor.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
.../include/tensorflow/core/framework/tensor.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
.../include/tensorflow/core/framework/tensor.pb.h:27:10: fatal error: google/protobuf/inlined_string_field.h: No such file or directory
 #include <google/protobuf/inlined_string_field.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

So, clearly this should be the issue:

This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer headers. Please update your headers.

and

fatal error: google/protobuf/inlined_string_field.h: No such file or directory

Tried solutions:

  1. I tried different versions of protobuf but there was an error every single try.
  2. I tried installing protobuf and eigen manually (without the download_dependencies.sh script)

I'm wondering because my own installation following exact the same steps works properly. Maybe there is an issue with one of the components unless I tried different versions to make sure that these aren't "new" issues.

Can someone help me solving this error that I can compile and run this project at the other machine?

Looking forward to get helpful solutions :) Thank you very much for the support!

Best regards from Germany!

Upvotes: 0

Views: 2001

Answers (2)

biying wang
biying wang

Reputation: 31

First, I checked on github, tensorflow r1.9 requires protobuf >=3.6.0. With download_dependencies.sh script, you always get protobuf 3.5.0, in which lack of inlined_string_field.h and some other headers.

Second, some errors that ask you to update protobuf version. I tried many versions of protobuf too. Only version 3.6.0 works well, rather than version 3.6.1 or older ones.

For these errors,

error This file was generated by a newer version of protoc which is

fatal error: google/protobuf/inlined_string_field.h: No such file or directory

It is a mismatch version problem. My solutions is that manually download protobuf 3.6.0 from https://github.com/protocolbuffers/protobuf/releases/download/v3.6.0/protoc-3.6.0-linux-x86_64.zip

install it and cp /usr/local/include/google to somewhere/tf/include. It works quite well for me. I don't know if you tried version 3.6.0.

download_dependencies.sh script would provide a mismatch version of protobuf. See the issue I posted on github https://github.com/tensorflow/tensorflow/issues/22536

Also, I noticed your copied files are different from mine. I did in this way.

sudo mkdir /usr/local/tensorflow/include
sudo cp -r tensorflow/contrib/makefile/downloads/eigen/Eigen /usr/local/tensorflow/include/
sudo cp -r tensorflow/contrib/makefile/downloads/eigen/unsupported /usr/local/tensorflow/include/
sudo cp -r tensorflow/contrib/makefile/gen/protobuf/include/google /usr/local/tensorflow/include/
sudo cp tensorflow/contrib/makefile/downloads/nsync/public/* /usr/local/tensorflow/include/
sudo cp -r bazel-genfiles/tensorflow /usr/local/tensorflow/include/
sudo cp -r tensorflow/cc /usr/local/tensorflow/include/tensorflow
sudo cp -r tensorflow/core /usr/local/tensorflow/include/tensorflow
sudo mkdir /usr/local/tensorflow/include/third_party
sudo cp -r third_party/eigen3 /usr/local/tensorflow/include/third_party/
sudo mkdir /usr/local/tensorflow/lib
sudo cp bazel-bin/tensorflow/libtensorflow_*.so /usr/local/tensorflow/lib

Btw, I run build_all_linux.sh instead of download_dependencies.sh.

I hope it will be helpful for you.

Upvotes: 1

Raiden
Raiden

Reputation: 1

I meet this problem before, following is my solution:

I successfully built tensorflow-r1.8 with bazel. And I found protoc in following path is 3.5.0:

/home/zsb/.cache/bazel/_bazel_zsb/1372f28eb0671f692e7ac38330377d8c/execroot/org_tensorflow/bazel-out/host/bin/external/protobuf_archive/protoc --version

but actually my system config is using protoc version 3.4.0 I confirmed this by type "protoc --version" directly.

So finally I update system protobuffer version to 3.5.0 and this problem fixed.

Upvotes: 0

Related Questions