question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find onnx/onnx.pb.h

See original GitHub issue

Whenever I try to include onnx/onnx_pb.h, I get a compilation error stating /usr/local/include/onnx/onnx_pb.h:52:26: fatal error: onnx/onnx.pb.h: No such file or directory compilation terminated.

It works fine in python though, but I want to parse ONNX models in C++.

I have tried to follow the instructions in #418 and #1001 but I think a specific solution would be more helpful.

I have the protobuf library installed. I have tried installing ONNX by following the instructions and finally running sudo python3 setup.py install. In the folder /home/sreenik/onnx/.setuptools-cmake-build/ when I type cmake -LA I get the following output: (a part is shown)

Protobuf_INCLUDE_DIR:PATH=/usr/include Protobuf_LIBRARY:FILEPATH=Protobuf_LIBRARY-NOTFOUND Protobuf_LIBRARY_DEBUG:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotobuf.so Protobuf_LIBRARY_RELEASE:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotobuf.so Protobuf_LITE_LIBRARY_DEBUG:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so Protobuf_LITE_LIBRARY_RELEASE:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotobuf-lite.so Protobuf_PROTOC_EXECUTABLE:FILEPATH=/usr/bin/protoc Protobuf_PROTOC_LIBRARY:FILEPATH=Protobuf_PROTOC_LIBRARY-NOTFOUND Protobuf_PROTOC_LIBRARY_DEBUG:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotoc.so Protobuf_PROTOC_LIBRARY_RELEASE:FILEPATH=/usr/lib/x86_64-linux-gnu/libprotoc.so pybind11_DIR:PATH=pybind11_DIR-NOTFOUND

As this didn’t work I tried to install it again by directly using cmake and make from the /onnx root directory. Even that did not work, however, cmake -LA showed the following: (a part is shown)

Protobuf_INCLUDE_DIR:PATH=/usr/local/include Protobuf_LIBRARY:FILEPATH=/usr/local/lib/libprotobuf.so Protobuf_LITE_LIBRARY_DEBUG:FILEPATH=/usr/local/lib/libprotobuf-lite.so Protobuf_LITE_LIBRARY_RELEASE:FILEPATH=/usr/local/lib/libprotobuf-lite.so Protobuf_PROTOC_EXECUTABLE:FILEPATH=/usr/local/bin/protoc Protobuf_PROTOC_LIBRARY:FILEPATH=/usr/local/lib/libprotoc.so

This detects the protobuf include dir path but still doesn’t solve the issue.

I have been trying to solve this for quite some time now, I think I might be missing something really simple, can someone please help me out?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:11

github_iconTop GitHub Comments

2reactions
maverickdascommented, Apr 20, 2019

@sreenikSS

I was able to reproduce your error. A possible workaround could be including the -DONNX_ML=1 flag while compiling using g++ as well as including the .setuptools-cmake-build directory. This looks like: g++ -DONNX_ML=1 test.cpp -o test -lprotobuf -I/path/to/onnx/repo/.setuptools-cmake-build/.

To understand what is happening after adding the mentioned flag, you should observe the onnx_pb.h file.

#ifdef ONNX_ML
#include "onnx/onnx-ml.pb.h"
#else
#include "onnx/onnx.pb.h"
#endif

Since onnx.pb.h is not available, but onnx-ml.pb.h is, setting the flag finds the required file.

What I am concerned about however is the repercussions of the said flag. Check out these two issues #1017 and #465

0reactions
jinfagangcommented, May 19, 2022

Can anybody point out why there is a onnx.proto and onnx-ml.proto? what’s the differences?

am using onnx-ml seems by default, but I can not get onnx::ModelProto any longer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missed header file onnx-ml.pb.h - Stack Overflow
Seems like onnx should be compiled during build time in directory ~/Projects/OpenVINO/cmake-build-debug/_deps/ext_onnx-src ... Maybe I've missed ...
Read more >
Missed header file onnx/onnx-ml.pb.h - Intel Communities
Hi all, I've faced with issue that: ~/Projects/OpenVINO/cmake-build-debug/_deps/ext_onnx-src/onnx/onnx_pb.h:50:10: fatal error: ...
Read more >
Preparation — onnxcustom
It is possible that onnx bugs are detected with onnxruntime pipeline runs. In such case the bugs shall be fixed in the onnx...
Read more >
Installing ONNX library on my Jetson Xavier
What errors do you get when trying to install the onnx package? This is what I do to install it: $ sudo apt-get...
Read more >
torch.onnx — PyTorch 1.13 documentation
The torch.onnx module can export PyTorch models to ONNX. ... Here is an example of handling missing symbolic function for the ELU operator....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found