cjweeks / tensorflow-cmake

Integrate TensorFlow with CMake projects effortlessly
MIT License
331 stars 83 forks source link

Protobuf version compatibility problem #13

Open zhn1010 opened 7 years ago

zhn1010 commented 7 years ago

Hi. Thanks for your very nice and effortless tutorial on building standalone tensorflow library.

Everything works fine when we use compiled libraries (tensorflow, protobuf, eigen) in console applications, but when I use them in Qt QWidget applications, we get runtime error of [libprotobuf FATAL google/protobuf/stubs/common.cc:78] This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.2.0)

To resolve this problem, can we link protobuf static library to tensorflow dynamic library? if yes how can we do that?

kleinma commented 6 years ago

I'm having this same problem when building with ROS applications using catkin/cmake and install Protobuf outside of /usr/local. I am able to set Protobuf_INCLUDE_DIRS and Protobuf_LIBRARIES to my local non-/usr/local directory. However, as the build continues, I run into this problem

In file included from /home/mak177/TensorFlow/TF_GPU_1_3/tensorflow_bymake/tensorflowinstall/include/google/tensorflow/tensorflow/core/framework/tensor.h:20:0,
                 from /home/mak177/TensorFlow/TF_GPU_1_3/tensorflow_bymake/tensorflowinstall/include/google/tensorflow/tensorflow/cc/framework/ops.h:21,
                 from /home/mak177/TensorFlow/TF_GPU_1_3/tensorflow_bymake/tensorflowinstall/include/google/tensorflow/tensorflow/cc/client/client_session.h:24,
                 from /home/mak177/ros_ws/src/glugun_sensor/glugun_laserscanner/include/glugun_laserscanner/glugun_laserscanner.h:11,
                 from /home/mak177/ros_ws/src/glugun_sensor/glugun_laserscanner/test/glugun_laserscanner_test.cpp:2:
/home/mak177/TensorFlow/TF_GPU_1_3/tensorflow_bymake/tensorflowinstall/include/google/tensorflow/tensorflow/core/framework/allocation_description.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
  ^
/home/mak177/TensorFlow/TF_GPU_1_3/tensorflow_bymake/tensorflowinstall/include/google/tensorflow/tensorflow/core/framework/allocation_description.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^
/home/mak177/TensorFlow/TF_GPU_1_3/tensorflow_bymake/tensorflowinstall/include/google/tensorflow/tensorflow/core/framework/allocation_description.pb.h:14:2: error: #error your headers.
 #error your headers.

Putting together each #error line, we get

#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please
#error regenerate this file with a newer version of protoc.

I am using Tensorflow r1.3. Through your method, I am installing Protobuf v3.3 into a directory in my home directory. When printing out my Protobuf_INCLUDE_DIRS and Protobuf_LIBRARIES, it finds this in my home directory just fine. In my /usr/include/google/protobuf/stubs/common.h I see that my system Protobuf install is v2.6.1. When we've copied all the Protobuf v3.3 stuff into /usr/include/ things work just fine. Is there a way to get our code to compile with catkin/cmake without replacing all the v2.6.1 stuff in /usr/include? If so, that would make our code much more portable from system to system.

Thanks for all of your hard work with this project! It's helped us immensely!

kleinma commented 6 years ago

It turns out I'm having the same problem with Eigen. I had to copy all the files over to /usr and replace the existing files. (note, not /usr/local. I never actually tried that.) Is it a common problem that installing eigen and protobuf in custom directories does not work, even when they are detected in cmake?

nkhdiscovery commented 6 years ago

Whoops, we have solved this in our case a few months ago, seems I have forgotten to document the final solution here and in other issues. I am currently on a trip, I will follow up ASAP.

nkhdiscovery commented 6 years ago

@kleinma take a look at last commits of branch fd-devel in our fork: https://github.com/Faraadid/tensorflow/tree/fd-devel?files=1

Hope it helps.

jhivesh commented 3 years ago

Using Tensorflow 1.14, I got another error below when changing protobuf to 3.8. AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'