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

Add support for matching Protobuf install #246

Merged
merged 18 commits into from
May 23, 2022
Merged

Add support for matching Protobuf install #246

merged 18 commits into from
May 23, 2022

Conversation

FloopCZ
Copy link
Owner

@FloopCZ FloopCZ commented Nov 17, 2020

Hi @xiandong79, feel free to try this if it helps.
cmake -DINSTALL_PROTOBUF=ON ..

Relates to #219

@xiandong79
Copy link

xiandong79 commented Nov 17, 2020

As I just touch tensorflow cpp, not sure how to resolve this error.

Background: I have build with the master branch, then, switch to system-protobuf branch, then run it with cmake -DSYSTEM_PROTOBUF=ON ..

ubuntu@ip-172-31-8-224:~/tensorflow_cc/tensorflow_cc/build$ cmake -DSYSTEM_PROTOBUF=ON ..
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.10/Modules/FindProtobuf.cmake:543 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:58 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/ubuntu/tensorflow_cc/tensorflow_cc/build/CMakeFiles/CMakeOutput.log".
See also "/home/ubuntu/tensorflow_cc/tensorflow_cc/build/CMakeFiles/CMakeError.log".

@FloopCZ
Copy link
Owner Author

FloopCZ commented Nov 17, 2020 via email

@xiandong79
Copy link

xiandong79 commented Nov 18, 2020

@FloopCZ

ubuntu@ip-172-31-8-224:~$ protoc --version
libprotoc 3.11.4

maybe I just do some wrong operations that I donot realize. sorry to waste your time.

the system protoc/Protobuf might be not applicable for tensorflow's need

@FloopCZ
Copy link
Owner Author

FloopCZ commented Nov 19, 2020

That is why I don't really like the idea of linking system protobuf. But this error is already when cmake calls find_package, which is weird. Can you ls -la /usr/lib/libprotobuf* please?

@cweigel
Copy link

cweigel commented Mar 10, 2021

Hi,

just my two cents / experiences about that.

  1. The system protobuf installation of @xiandong79 may only contain the runtime files - not the development files or might be in the wrong version

  2. We've also ran into the issue with missing protobuf - the thing is that protobuf is very picky to match its exact version therefore we've compile protobuf (the static protobuf.a) in exactly the version that was used in the respective tensorflow version and linked it to our main program. I also tried to compile it form the source code version that is downloaded by bazel during the tensorflow build but that is somehow a "special" reduced version.

  3. A better approach to resolve this within this project would probably be to 1. find out which version is used and 2. add this version as another external project to this repo.

@FloopCZ FloopCZ linked an issue Jun 29, 2021 that may be closed by this pull request
@FloopCZ FloopCZ linked an issue May 21, 2022 that may be closed by this pull request
@FloopCZ
Copy link
Owner Author

FloopCZ commented May 21, 2022

@xiandong79 @cweigel According to your suggestions, there is an option -DINSTALL_PROTOBUF=ON which installs a Protobuf version compatible with the current TensorFlow version. You still have to use find_package(Protobuf) and link the Protobuf library to your executable, but by default, it should be installed in /usr/local and CMake should prefer it to your system Protobuf.

@FloopCZ FloopCZ marked this pull request as ready for review May 21, 2022 19:52
@FloopCZ FloopCZ changed the base branch from master to v2.9.0 May 21, 2022 19:52
Base automatically changed from v2.9.0 to master May 23, 2022 20:01
@FloopCZ FloopCZ changed the title Allow linkage to system protobuf Add support for matching Protobuf install May 23, 2022
@FloopCZ FloopCZ merged commit c8c90a4 into master May 23, 2022
@FloopCZ FloopCZ deleted the system-protobuf branch May 23, 2022 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment