onnx / onnx-tensorrt

ONNX-TensorRT: TensorRT backend for ONNX
Apache License 2.0
2.95k stars 544 forks source link

cannot build onnx-tensorrt successful #822

Closed Biaocsu closed 2 years ago

Biaocsu commented 2 years ago

TensorRT

1、git clone https://github.com/NVIDIA/TensorRT
2、cd TensorRT
3、./docker/build.sh --file docker/ubuntu-18.04.Dockerfile --tag tensorrt-ubuntu18.04-cuda11.4
4、./docker/launch.sh --tag tensorrt-ubuntu18.04-cuda11.4 --gpus all

protobuf

5、wget https:///protocolbuffers/protobuf/releases/download/v3.20.0-rc2/protobuf-all-3.20.0-rc-2.tar.gz
6、tar -zvxf protobuf-all-3.20.0-rc-2.tar.gz
7、cd protobuf-3.20.0-rc-2
8、./configure
9、sudo make
10、sudo make check
11、sudo make install
12、sudo ldconfig
which protoc
/usr/local/bin/protoc

protoc --version
libprotoc 3.20.0-rc2

onnx-tensorrt

13、git clone https://github.com/onnx/onnx-tensorrt
14、mkdir build && cd build
15、cmake .. -DTENSORRT_ROOT=/home/TensorRT && make -j

here is the error:

[ 87%] Building CXX object CMakeFiles/nvonnxparser_static.dir/OnnxAttrs.cpp.o
[ 88%] Building CXX object CMakeFiles/nvonnxparser_static.dir/ShapeTensor.cpp.o
[ 89%] Building CXX object CMakeFiles/nvonnxparser.dir/ShapeTensor.cpp.o
[ 90%] Building CXX object CMakeFiles/nvonnxparser_static.dir/onnxErrorRecorder.cpp.o
[ 70%] Building CXX object CMakeFiles/nvonnxparser_static.dir/builtin_op_importers.cpp.o
In file included from /home/onnx-tensorrt/third_party/onnx/onnx/defs/shape_inference.h:4:0,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/defs/schema.h:24,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/defs/schema.cc:4:
/home/onnx-tensorrt/third_party/onnx/onnx/proto_utils.h: In function 'bool onnx2trt_onnx::ParseProtoFromBytes(Proto*, const char*, size_t)':
/home/onnx-tensorrt/third_party/onnx/onnx/proto_utils.h:34:66: error: no matching function for call to 'google::protobuf::io::CodedInputStream::SetTotalBytesLimit(long long int, long long int)'
   coded_stream.SetTotalBytesLimit((2048LL << 20) - 1, 512LL << 20);
                                                                  ^
In file included from /home/onnx-tensorrt/build/third_party/onnx/onnx/onnx_onnx2trt_onnx-ml.pb.h:23:0,
                 from /home/onnx-tensorrt/build/third_party/onnx/onnx/onnx-ml.pb.h:2,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/onnx_pb.h:50,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/defs/data_type_utils.h:11,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/defs/schema.h:21,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/defs/schema.cc:4:
/usr/local/include/google/protobuf/io/coded_stream.h:407:8: note: candidate: void google::protobuf::io::CodedInputStream::SetTotalBytesLimit(int)
   void SetTotalBytesLimit(int total_bytes_limit);
        ^~~~~~~~~~~~~~~~~~
/usr/local/include/google/protobuf/io/coded_stream.h:407:8: note:   candidate expects 1 argument, 2 provided
In file included from /home/onnx-tensorrt/third_party/onnx/onnx/defs/shape_inference.h:4:0,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/defs/schema.h:24,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/defs/object_detection/old.cc:4:
/home/onnx-tensorrt/third_party/onnx/onnx/proto_utils.h: In function 'bool onnx2trt_onnx::ParseProtoFromBytes(Proto*, const char*, size_t)':
/home/onnx-tensorrt/third_party/onnx/onnx/proto_utils.h:34:66: error: no matching function for call to 'google::protobuf::io::CodedInputStream::SetTotalBytesLimit(long long int, long long int)'
   coded_stream.SetTotalBytesLimit((2048LL << 20) - 1, 512LL << 20);

......

/home/onnx-tensorrt/third_party/onnx/onnx/proto_utils.h: In function 'bool onnx2trt_onnx::ParseProtoFromBytes(Proto*, const char*, size_t)':
/home/onnx-tensorrt/third_party/onnx/onnx/proto_utils.h:34:66: error: no matching function for call to 'google::protobuf::io::CodedInputStream::SetTotalBytesLimit(long long int, long long int)'
   coded_stream.SetTotalBytesLimit((2048LL << 20) - 1, 512LL << 20);
                                                                  ^
In file included from /home/onnx-tensorrt/build/third_party/onnx/onnx/onnx_onnx2trt_onnx-ml.pb.h:23:0,
                 from /home/onnx-tensorrt/build/third_party/onnx/onnx/onnx-ml.pb.h:2,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/onnx_pb.h:50,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/common/tensor.h:10,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/common/ir.h:23,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/optimizer/optimize.h:6,
                 from /home/onnx-tensorrt/third_party/onnx/onnx/optimizer/optimize.cc:4:
/usr/local/include/google/protobuf/io/coded_stream.h:407:8: note: candidate: void google::protobuf::io::CodedInputStream::SetTotalBytesLimit(int)
   void SetTotalBytesLimit(int total_bytes_limit);
        ^~~~~~~~~~~~~~~~~~
/usr/local/include/google/protobuf/io/coded_stream.h:407:8: note:   candidate expects 1 argument, 2 provided
third_party/onnx/CMakeFiles/onnx.dir/build.make:322: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/object_detection/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/object_detection/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:465: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/tensor/utils.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/tensor/utils.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:413: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/schema.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/schema.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:400: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/rnn/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/rnn/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:309: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/object_detection/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/object_detection/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:153: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/controlflow/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/controlflow/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:218: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/generator/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/generator/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:426: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/sequence/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/sequence/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:361: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/reduction/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/reduction/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:231: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/logical/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/logical/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:517: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/traditionalml/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/traditionalml/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:348: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/quantization/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/quantization/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:335: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/quantization/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/quantization/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:114: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/common/model_helpers.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/common/model_helpers.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:192: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/function.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/function.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:374: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/reduction/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/reduction/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:244: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/logical/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/logical/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:387: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/rnn/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/rnn/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:504: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/traditionalml/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/traditionalml/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:530: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/training/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/training/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:296: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/nn/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/nn/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:166: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/controlflow/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/controlflow/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:205: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/generator/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/generator/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:257: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/math/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/math/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:595: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/optimizer/pass_registry.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/optimizer/pass_registry.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:439: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/tensor/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/tensor/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:608: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/shape_inference/implementation.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/shape_inference/implementation.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:452: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/tensor/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/tensor/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:270: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/math/old.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/math/old.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:62: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/checker.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/checker.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:283: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/nn/defs.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/defs/nn/defs.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:556: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/optimizer/optimize.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/optimizer/optimize.cc.o] Error 1
third_party/onnx/CMakeFiles/onnx.dir/build.make:621: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/onnx/version_converter/convert.cc.o' failed
make[2]: *** [third_party/onnx/CMakeFiles/onnx.dir/onnx/version_converter/convert.cc.o] Error 1
CMakeFiles/Makefile2:248: recipe for target 'third_party/onnx/CMakeFiles/onnx.dir/all' failed
make[1]: *** [third_party/onnx/CMakeFiles/onnx.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 91%] Linking CXX shared library libnvonnxparser.so
[ 93%] Linking CXX static library libnvonnxparser_static.a
[ 93%] Built target nvonnxparser_static
[ 93%] Built target nvonnxparser
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

please help, it has troubled me for a few days. question: 1、do I install Protobuf correctly ? how to verify or how to install it in detail and simply 2、else where, please help find it

Biaocsu commented 2 years ago

can anyone help solve this problem?

kevinch-nv commented 2 years ago

The main branch has a dependency on ONNX 1.8, which does not support the latest version of protobuf.

Try installing an older version, such as 3.11 and build again

Biaocsu commented 2 years ago

@kevinch-nv thanks, it worked

akshaygulabrao commented 1 year ago

thank you @Biaocsu, I had this same problem