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

[Build] Can't build on Arch using protobuf packages #22569

Closed
vlovich opened this issue Oct 24, 2024 · 2 comments
Closed

[Build] Can't build on Arch using protobuf packages #22569

vlovich opened this issue Oct 24, 2024 · 2 comments
Labels
build build issues; typically submitted using template

Comments

@vlovich
Copy link

vlovich commented Oct 24, 2024

Describe the issue

Arch by default installs the latest protobuf which is incompatible due to removal of ReleaseCleared in v26 & above (as noted in #21308 ). So I install the protobuf-21 package which is the preferred version for ONNX. I then set the protoc path to ONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc-21 but then that fails because the build picks up the /usr/include/google/protobuf which is incompatible - the protobuf-21 package installs the includes into /usr/include/protobuf-21/google/protobuf so as not to conflict with any other version. I'm at a loss as to how to get ONNX to compile against the system protobuf-21 package (i.e. how do I override the protobuf library include path).

Urgency

No response

Target platform

Arch Linux

Build script

NVCC_CCBIN='/usr/bin/g++-13' CUDA_PATH=/opt/cuda PATH=/opt/cuda/bin:$PATH CC=gcc-13 CXX=g++-13 ./build.sh --use_cuda --cudnn_home /usr --cuda_home /opt/cuda --cmake_extra_defines CMAKE_CUDA_ARCHITECTURES=75 --cmake_extra_defines onnxruntime_ENABLE_NVTX_PROFILE=ON --cmake_extra_defines ONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc-21 --enable_cuda_line_info

Error / output

If building against normal protobuf,

~/projects/onnxruntime/onnxruntime/core/graph/graph.cc:1291:58: error: ‘class google::protobuf::RepeatedPtrField<onnx::SparseTensorProto>’ has no member named ‘ReleaseCleared’
 1291 |       delete graph_proto_->mutable_sparse_initializer()->ReleaseCleared();

If building against protobuf-21 (--cmake_extra_defines ONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc-21)

In file included from ~/projects/onnxruntime/build/Linux/Debug/_deps/onnx-build/onnx/onnx-ml.pb.cc:4:
~/projects/onnxruntime/build/Linux/Debug/_deps/onnx-build/onnx/onnx-ml.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
   12 | #error This file was generated by a newer version of protoc which is
      |  ^~~~~
~/projects/onnxruntime/build/Linux/Debug/_deps/onnx-build/onnx/onnx-ml.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
   13 | #error incompatible with your Protocol Buffer headers. Please update
      |  ^~~~~
~/projects/onnxruntime/build/Linux/Debug/_deps/onnx-build/onnx/onnx-ml.pb.h:14:2: error: #error your headers.
   14 | #error your headers.
      |  ^~~~~

Visual Studio Version

No response

GCC / Compiler Version

gcc-13

@vlovich vlovich added the build build issues; typically submitted using template label Oct 24, 2024
@vlovich vlovich changed the title [Build] Protobuf conflict building on Arch [Build] Can't build on Arch using protobuf packages Oct 24, 2024
@vlovich
Copy link
Author

vlovich commented Oct 24, 2024

Found the magic variable I think: --cmake_extra_defines PROTOBUF_INCLUDE_DIRS=/usr/include/protobuf-21/

@vlovich vlovich closed this as completed Oct 24, 2024
@cyanic-selkie
Copy link

@vlovich I had the same problem, but adding --cmake_extra_defines PROTOBUF_INCLUDE_DIRS=/usr/include/protobuf-21 ONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc-21 only made it compile, the linking still fails. Did you do anything else other than install the protobuf-21 package and add those two flags?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

No branches or pull requests

2 participants