Giter VIP home page Giter VIP logo

onnx_runtime_cpp's Introduction

Build

If this work somehow makes your day, maybe you can consider :)

"Buy Me A Coffee"

small c++ library to quickly use onnxruntime to deploy deep learning models

Thanks to cardboardcode, we have the documentation for this small library. Hope that they both are helpful for your work.

Table of Contents
  1. TODO
  2. Installation
  3. How to Build
  4. How to test apps

TODO

Installation

  • build onnxruntime from source with the following script
    # onnxruntime needs newer cmake version to build
    bash ./scripts/install_latest_cmake.bash


    bash ./scripts/install_onnx_runtime.bash

    # dependencies to build apps
    bash ./scripts/install_apps_dependencies.bash

How to build


CPU
make default

# build examples
make apps
GPU with CUDA
make gpu_default

make gpu_apps

How to Run with Docker

CPU
# build
docker build -f ./dockerfiles/ubuntu2004.dockerfile -t onnx_runtime .

# run
docker run -it --rm -v `pwd`:/workspace onnx_runtime
GPU with CUDA
# build
# change the cuda version to match your local cuda version before build the docker

docker build -f ./dockerfiles/ubuntu2004_gpu.dockerfile -t onnx_runtime_gpu .

# run
docker run -it --rm --gpus all -v `pwd`:/workspace onnx_runtime_gpu
  • Onnxruntime will be built with TensorRT support if the environment has TensorRT. Check this memo for useful URLs related to building with TensorRT.
  • Be careful to choose TensorRT version compatible with onnxruntime. A good guess can be inferred from HERE.
  • Also it is not possible to use models whose input shapes are dynamic with TensorRT backend, according to this

How to test apps


Image Classification With Squeezenet


Usage
# after make apps
./build/examples/TestImageClassification ./data/squeezenet1.1.onnx ./data/images/dog.jpg

the following result can be obtained

264 : Cardigan, Cardigan Welsh corgi : 0.391365
263 : Pembroke, Pembroke Welsh corgi : 0.376214
227 : kelpie : 0.0314975
158 : toy terrier : 0.0223435
230 : Shetland sheepdog, Shetland sheep dog, Shetland : 0.020529

(back to top)

Object Detection With Tiny-Yolov2 trained on VOC dataset (with 20 classes)


Usage
  • Download model from onnx model zoo: HERE

  • The shape of the output would be

    OUTPUT_FEATUREMAP_SIZE X OUTPUT_FEATUREMAP_SIZE * NUM_ANCHORS * (NUM_CLASSES + 4 + 1)
    where OUTPUT_FEATUREMAP_SIZE = 13; NUM_ANCHORS = 5; NUM_CLASSES = 20 for the tiny-yolov2 model from onnx model zoo
  • Test tiny-yolov2 inference apps
# after make apps
./build/examples/tiny_yolo_v2 [path/to/tiny_yolov2/onnx/model] ./data/images/dog.jpg

(back to top)

Object Instance Segmentation With MaskRCNN trained on MS CoCo Dataset (80 + 1(background) clasess)


Usage
  • Download model from onnx model zoo: HERE

  • As also stated in the url above, there are four outputs: boxes(nboxes x 4), labels(nboxes), scores(nboxes), masks(nboxesx1x28x28)

  • Test mask-rcnn inference apps

# after make apps
./build/examples/mask_rcnn [path/to/mask_rcnn/onnx/model] ./data/images/dogs.jpg

(back to top)

Yolo V3 trained on Ms CoCo Dataset


Usage
  • Download model from onnx model zoo: HERE

  • Test yolo-v3 inference apps

# after make apps
./build/examples/yolov3 [path/to/yolov3/onnx/model] ./data/images/no_way_home.jpg

(back to top)


Usage
# after make apps
./build/examples/ultra_light_face_detector ./data/version-RFB-640.onnx ./data/images/endgame.jpg

(back to top)


Usage
  • Download onnx model trained on COCO dataset from HERE
# this app tests yolox_l model but you can try with other yolox models also.
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_l.onnx -O ./data/yolox_l.onnx
  • Test inference apps
# after make apps
./build/examples/yolox ./data/yolox_l.onnx ./data/images/matrix.jpg

(back to top)


Usage
  • Download PaddleSeg's bisenetv2 trained on cityscapes dataset that has been converted to onnx HERE and copy to ./data directory
You can also convert your own PaddleSeg with following procedures
  • Test inference apps
./build/examples/semantic_segmentation_paddleseg_bisenetv2 ./data/bisenetv2_cityscapes.onnx ./data/images/sample_city_scapes.png
./build/examples/semantic_segmentation_paddleseg_bisenetv2 ./data/bisenetv2_cityscapes.onnx ./data/images/odaiba.jpg

(back to top)


Usage
  • Convert SuperPoint's pretrained weights to onnx format
git submodule update --init --recursive
python3 -m pip install -r scripts/superpoint/requirements.txt
python3 scripts/superpoint/convert_to_onnx.py
wget https://raw.githubusercontent.com/StaRainJ/Multi-modality-image-matching-database-metrics-methods/master/Multimodal_Image_Matching_Datasets/ComputerVision/CrossSeason/VisionCS_0a.png -P data

wget https://raw.githubusercontent.com/StaRainJ/Multi-modality-image-matching-database-metrics-methods/master/Multimodal_Image_Matching_Datasets/ComputerVision/CrossSeason/VisionCS_0b.png -P data
  • Test inference apps
./build/examples/super_point /path/to/super_point.onnx data/VisionCS_0a.png data/VisionCS_0b.png

(back to top)


Usage
  • Convert SuperPoint's pretrained weights to onnx format: Follow the above instruction

  • Convert SuperGlue's pretrained weights to onnx format

git submodule update --init --recursive
python3 -m pip install -r scripts/superglue/requirements.txt
python3 -m pip install -r scripts/superglue/SuperGluePretrainedNetwork/requirements.txt
python3 scripts/superglue/convert_to_onnx.py
  • Download test images from this dataset: Or prepare some pairs of your own images

  • Test inference apps

./build/examples/super_glue /path/to/super_point.onnx /path/to/super_glue.onnx /path/to/1st/image /path/to/2nd/image

(back to top)


Usage
  • Download LoFTR weights indoords_new.ckpt from HERE. (LoFTR's latest commit seems to be only compatible with the new weights (Ref: zju3dv/LoFTR#48). Hence, this onnx cpp application is only compatible with _indoor_ds_new.ckpt weights)

  • Convert LoFTR's pretrained weights to onnx format

git submodule update --init --recursive
python3 -m pip install -r scripts/loftr/requirements.txt
python3 scripts/loftr/convert_to_onnx.py --model_path /path/to/indoor_ds_new.ckpt
  • Download test images from this dataset: Or prepare some pairs of your own images

  • Test inference apps

./build/examples/loftr /path/to/loftr.onnx /path/to/loftr.onnx /path/to/1st/image /path/to/2nd/image

(back to top)

onnx_runtime_cpp's People

Contributors

xmba15 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

onnx_runtime_cpp's Issues

hello,when i run C++ onnxruntime for superglue ,have some erro 。

[E:onnxruntime:, sequential_executor.cc:364 Execute] Non-zero status code returned while running Add node. Name:'Add_1406' Status Message: /media/xh/66a02c6b-02b4-44e5-96f6-d40842b4e261/DBT_TRT/SuperGlue_TRT/onnxruntime/onnxruntime/core/providers/cpu/math/element_wise_ops.h:503 void onnxruntime::BroadcastIterator::Init(ptrdiff_t, ptrdiff_t) axis == 1 || axis == largest was false. Attempting to broadcast an axis by a dimension other than 1. 383 by 736

Question about TensorRT environment

Hi! Thanks for your great work. The onnx_runtime_gpu version works fine to me, and I'm trying to deploy a faster TensorRT version.
I've followed the instructions of onnxruntime_tensorrt.md to build a TensorRT docker, however there are errors while building onnx_runtime. I want to know which version of onnx_runtime and TensorRT docker tag did you use to test?
BTW, the TensoRT docker tag in your dockerfile is 21.07-py3, and the script install_onnx_runtime.bash seems to install an onnx_runtime version v1.14.1.
Looking forward to your reply!

Hello, I need to get a fixed-size input-output model. When converting the loftr.onnx file, it can be converted successfully, but it is a verification model, and this error occurs.

Hello, I need to get a fixed-size input-output model. When converting the loftr.onnx file, it can be converted successfully, but it is a verification model, and this error occurs.
nvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : Load model from /data01/pot/onnx_runtime_cpp/scripts/loftr/loftr_static.onnx failed:This is an invalid model. Type Error: Type 'tensor(bool)' of input parameter (onnx::Mul_2835) of operator (Mul) in node (Mul_1875) is invalid.

build error

when I run make apps , have some error :
/Users/admin/Desktop/onnx_runtime_cpp-master/include/ort_utility/Utility.hpp:92:26: error: no viable conversion from 'deque<size_t>' to 'deque<uint64_t>'
std::deque<uint64_t> sortedIndices = ::sortIndexes(scores);
/Users/admin/Desktop/onnx_runtime_cpp-master/include/ort_utility/Utility.hpp:123:45: error: type 'const std::array<float, 4>' does not provide a subscript operator
float tmpXmin = std::max(curBbox[0], bbox[0]);
/Users/admin/Desktop/onnx_runtime_cpp-master/include/ort_utility/Utility.hpp:124:45: error: type 'const std::array<float, 4>' does not provide a subscript operator
float tmpYmin = std::max(curBbox[1], bbox[1]);
...........
how to deal it ?

[install_onnx_runtime.sh] Build Error: need to install cuda package

Hi xmba15, thank you for creating this C++ library for running onnxruntime.

This issue has been resolved. This post is only to record a frequent error I faced as well as the remedy for it.

Issue Description

Running the command as shown in README.md,

sudo bash ./scripts/install_onnx_runtime.sh
generates the build failure showing the following error in terminal:
/usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin


checking dependencies...

need to install cuda package

This error is caused because the command nvcc fails to execute based on the script.

If like me, running nvcc -V in terminal works fine but the error persists, do the following to resolve the issue.

Solution

After line 5 of install_onnx_runtime.sh, add the following lines.

export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
export PATH=$PATH:$CUDA_HOME/bin

Expected vs actual output shape

Hello, I'm using the MaskRCNN example here to test my code in C++.

I converted my own MaskRCNN model from Pytorch 1.9.0, and in Python, I was able to run the model through onnxruntime and get the expected 8 detections in my input image.

On the C++ side however, I get this:
2021-10-01 12:42:06.151886544 [W:onnxruntime:, execution_frame.cc:770 VerifyOutputSizes] Expected shape from model of {8,1,909,909} does not match actual shape of {0,1,909,909} for output 3788, which results in 0 detections found.

Have you seen this before, or have an idea of what might be going on?

Thanks!

Creating API documentation for onnx_runtime_cpp

Hi @xmba15,

My enquiry is:

Are you currently working on documenting this codebase's API?

If not, is it okay if I contribute by doing the API documentation?

I find the examples you have included in this repository to be very useful in helping to understand how one can apply onnxruntime in CPP. I believe more can benefit from your code better when there is more documentation showing the underlying structures.

bug?

Traceback (most recent call last):
File "convert_to_onnx.py", line 71, in
main()
File "convert_to_onnx.py", line 36, in main
torch.onnx.export(
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/onnx/init.py", line 225, in export
return utils.export(model, args, f, export_params, verbose, training,
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/onnx/utils.py", line 85, in export
_export(model, args, f, export_params, verbose, training, input_names, output_names,
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/onnx/utils.py", line 632, in _export
_model_to_graph(model, args, verbose, input_names,
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/onnx/utils.py", line 409, in _model_to_graph
graph, params, torch_out = _create_jit_graph(model, args,
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/onnx/utils.py", line 379, in _create_jit_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args)
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/onnx/utils.py", line 342, in _trace_and_get_graph_from_model
torch.jit._get_trace_graph(model, args, strict=False, _force_outplace=False, _return_inputs_states=True)
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/jit/_trace.py", line 1148, in _get_trace_graph
outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/jit/_trace.py", line 125, in forward
graph, out = torch._C._create_graph_by_tracing(
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/jit/_trace.py", line 116, in wrapper
outs.append(self.inner(*trace_inputs))
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/nn/modules/module.py", line 725, in _call_impl
result = self._slow_forward(*input, **kwargs)
File "/root/anaconda3/envs/eys/lib/python3.8/site-packages/torch/nn/modules/module.py", line 709, in _slow_forward
result = self.forward(*input, **kwargs)
TypeError: forward() missing 7 required positional arguments: 'scores0', 'keypoints0', 'descriptors0', 'image1_shape', 'scores1', 'keypoints1', and 'descriptors1'

运行superglue 中的convert_to_onnx.py 报错如下,不懂怎么解决,求助

Loaded SuperGlue model ("indoor" weights)
/home/xh/.local/lib/python3.6/site-packages/torch/onnx/utils.py:363: UserWarning: Skipping _decide_input_format
-1
warnings.warn("Skipping _decide_input_format\n {}".format(e.args[0]))
Traceback (most recent call last):
File "convert_to_onnx.py", line 71, in
main()
File "convert_to_onnx.py", line 55, in main
"matching_scores1": {0: "batch_size", 1: "num_keypoints1"},
File "/home/xh/.local/lib/python3.6/site-packages/torch/onnx/init.py", line 320, in export
custom_opsets, enable_onnx_checker, use_external_data_format)
File "/home/xh/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 111, in export
custom_opsets=custom_opsets, use_external_data_format=use_external_data_format)
File "/home/xh/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 729, in _export
dynamic_axes=dynamic_axes)
File "/home/xh/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 493, in _model_to_graph
graph, params, torch_out, module = _create_jit_graph(model, args)
File "/home/xh/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 437, in _create_jit_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args)
File "/home/xh/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 388, in _trace_and_get_graph_from_model
torch.jit._get_trace_graph(model, args, strict=False, _force_outplace=False, _return_inputs_states=True)
File "/home/xh/.local/lib/python3.6/site-packages/torch/jit/_trace.py", line 1166, in _get_trace_graph
outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
File "/home/xh/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/xh/.local/lib/python3.6/site-packages/torch/jit/_trace.py", line 132, in forward
self._force_outplace,
File "/home/xh/.local/lib/python3.6/site-packages/torch/jit/_trace.py", line 118, in wrapper
outs.append(self.inner(*trace_inputs))
File "/home/xh/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/xh/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1090, in _slow_forward
result = self.forward(*input, **kwargs)
TypeError: forward() missing 7 required positional arguments: 'scores0', 'keypoints0', 'descriptors0', 'image1_shape', 'scores1', 'keypoints1', and 'descriptors1'

This problem occurs when I use tensorrt as the backend run superglue. Please give me some advice! Thank you.

./super_glue super_point.onnx super_glue.onnx 1.png 2.png

if (m_gpuIdx.has_value()) {
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_Tensorrt(sessionOptions, m_gpuIdx.value()));
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_CUDA(sessionOptions, m_gpuIdx.value()));

terminate called after throwing an instance of 'Ort::Exception'
what(): Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc:798 SubGraphCollection_t onnxruntime::TensorrtExecutionProvider::GetSupportedList(SubGraphCollection_t, int, int, const onnxruntime::GraphViewer&, bool*) const [ONNXRuntimeError] : 1 : FAIL : TensorRT input: onnx::Where_3463 has no shape specified. Please run shape inference on the onnx model first. Details can be found in https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html#shape-inference-for-tensorrt-subgraphs

ASpanFormer (LofTR-like) support

Hi, would it be possible to create an example for ASpanFormer model, a loftr like model, that is mostly using the same code as loftr.
I tried to implement it using your loftr example, but first, got an error from onnx saying that the opset 12 doesn't support grid_sampler. error below:
Exception has occurred: UnsupportedOperatorError Exporting the operator 'aten::grid_sampler' to ONNX opset version 12 is not supported. Support for this operator was added in version 16, try exporting with this version. File "convert_to_onnx_aspan.py", line 35, in main torch.onnx.export( File "convert_to_onnx_aspan.py", line 70, in <module> main()
After setting the opset version to 16, the code successfully exported the onnx model, but when calling the inferenceSession as sess = onnxruntime.InferenceSession("aspanformer.onnx") got another error saying:
Exception has occurred: InvalidGraph [ONNXRuntimeError] : 10 : INVALID_GRAPH : Load model from aspanformer.onnx failed:This is an invalid model. Type Error: Type 'tensor(bool)' of input parameter (/coarse_matching/And_1_output_0) of operator (ReduceMax) in node (/coarse_matching/ReduceMax_2) is invalid.

The exported model even passes the onnx.checker.check_model validation.

Any help would be great, and thanks for the good work.

how to build?

Where should I build from? Can you explain it in detail? For example, how to run yolov3app?
Thanks!

在哪个位置执行编译?

/onnx_runtime_cpp/build$ 下面执行

cmake ..
make all

报错
[ 20%] Building CXX object src/CMakeFiles/ort_utility.dir/ImageClassificationOrtSessionHandler.cpp.o In file included from /home/zhb/pytorch_project/onnx_runtime_cpp/./include/ort_utility/ImageRecognitionOrtSessionHandlerBase.hpp:16:0, from /home/zhb/pytorch_project/onnx_runtime_cpp/./include/ort_utility/ImageClassificationOrtSessionHandler.hpp:16, from /home/zhb/pytorch_project/onnx_runtime_cpp/./include/ort_utility/ort_utility.hpp:14, from /home/zhb/pytorch_project/onnx_runtime_cpp/src/ImageClassificationOrtSessionHandler.cpp:14: /home/zhb/pytorch_project/onnx_runtime_cpp/./include/ort_utility/OrtSessionHandler.hpp:15:20: fatal error: optional: No such file or directory compilation terminated. src/CMakeFiles/ort_utility.dir/build.make:62: recipe for target 'src/CMakeFiles/ort_utility.dir/ImageClassificationOrtSessionHandler.cpp.o' failed make[2]: *** [src/CMakeFiles/ort_utility.dir/ImageClassificationOrtSessionHandler.cpp.o] Error 1 CMakeFiles/Makefile2:90: recipe for target 'src/CMakeFiles/ort_utility.dir/all' failed make[1]: *** [src/CMakeFiles/ort_utility.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

About loftr.onnx

Hello, it was not when you transferred the .onnx model, what operator was rewritten, I encountered a problem when using the loftr.onnx you provided to convert the dlc file
Traceback (most recent call last): File "/data01/software/snpe/lib/python/qti/aisw/converters/onnx/onnx_to_ir.py", line 330, in convert src_op.op_type) File "/data01/software/snpe/lib/python/qti/aisw/converters/common/converter_ir/translation.py", line 48, in apply_method_to_op translation = self.__get_translation(op_type) File "/data01/software/snpe/lib/python/qti/aisw/converters/common/converter_ir/translation.py", line 35, in __get_translation raise KeyError("No translation registered for op type {}.".format(op_type)) KeyError: 'No translation registered for op type onnx_einsum.' 2023-03-29 14:57:0

/usr/bin/ld: ../src/libort_utility.so: undefined reference to `OrtSessionOptionsAppendExecutionProvider_CUDA'

when I run make gpu_apps command, got some error:

[ 20%] Linking CXX executable TestImageClassification
/usr/bin/ld: ../src/libort_utility.so: undefined reference to `OrtSessionOptionsAppendExecutionProvider_CUDA'
collect2: error: ld returned 1 exit status
make[5]: *** [examples/CMakeFiles/TestImageClassification.dir/build.make:152:examples/TestImageClassification] error 1

I have cuda11.5 in my ubuntu20.04

docker build -f ./dockerfiles/ubuntu2004.dockerfile -t onnx_runtime . FAIL

docker build -f ./dockerfiles/ubuntu2004.dockerfile -t onnx_runtime .

| >>> RUN apt-get update && \
   9 | >>>     apt-get install -y --no-install-recommends \
  10 | >>>         sudo \
  11 | >>>         gnupg2 \
  12 | >>>         lsb-release \
  13 | >>>         build-essential \
  14 | >>>         software-properties-common \
  15 | >>>         cmake \
  16 | >>>         git \
  17 | >>>         tmux && \
  18 | >>>     bash install_latest_cmake.bash && \
  19 | >>>     bash install_onnx_runtime.bash && \
  20 | >>>     bash install_apps_dependencies.bash && \
  21 | >>>     rm -rf /build && \
  22 | >>>     apt-get clean && \
  23 | >>>     rm -rf /var/lib/apt/lists/*
  24 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update &&     apt-get install -y --no-install-recommends         sudo         gnupg2         lsb-release         build-essential         software-properties-common         cmake         git         tmux &&     bash install_latest_cmake.bash &&     bash install_onnx_runtime.bash &&     bash install_apps_dependencies.bash &&     rm -rf /build &&     apt-get clean &&     rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 100

[install_onnx_runtime.sh] Build Error: error: call of overloaded ‘abs(__gnu_cxx::__alloc_traits<std::allocator<float> >::value_type)’ is ambiguous

Hi xmba15, thank you for creating this C++ library for running onnxruntime.

This issue has been resolved. This post is only to record an error I faced as well as the remedy for it.

Issue Description

Build fails, reporting the following error compiling test_inference.cc which is downloaded under the transitional onnxruntime directory.

error: call of overloaded ‘abs(__gnu_cxx::__alloc_traits<std::allocator<float> >::value_type)’ is ambiguous
     ASSERT_TRUE(std::abs(values_y[i] - f[i]) < 1e-6);

Solution

Replace line 18 of onnx_runtime_cpp/onnxruntime/onnxruntime/test/global_thread_pools/test_inference.cc
from the one below:

#include <stdlib.h>

With this line:

#include <cmath>

This stackoverflow discussion thread could explain why this modification works.

[make Error] optional: No such file or directory

This issue has been resolved. This post is only to record an error I faced as well as the remedy for it.

Issue Description

Running make all fails and generates make error

optional: No such file or directory

This is caused by an incompatible g++ version. The g++ version to run the command make all successfully is g++7

To check your current g++ version, run the command:

g++ --version

Solution

Install or change your default g++ version
For installing

sudo apt-get install g++-7.5
For changing
sudo update-alternatives --config g++
Then choose g++7 and above.

Error about OrtSessionHandler.cpp

m_session = Ort::Session(m_env, m_modelPath.c_str(), sessionOptions);

I'm trying to compile programs under win10.I use this runtime package.
https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.gpu
Then it reported an error.
Severity Code Description Item File Line Disabled Display Status Details Error (active) E0289 No constructor "Ort::Session::Session" instance ort_utility D:\CODE\onnx_runtime_cpp\src\OrtSessionHandler.cpp 204 Parameters of type: ( Ort::Env, const char *, Ort::SessionOptions)
In onnxruntime_cxx_api.h, the parameter types seem to be different from the ones used.

struct Session : Base<OrtSession> {
  explicit Session(std::nullptr_t) {}
  Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options);
  Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options);

linked by target "ort_utility" in directory

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
onnxruntime_LIBS
linked by target "ort_utility" in directory /source/code/AI/src/inference/OnnxRT/CppDeploy/samples/onnx_runtime_cpp/src

-- Configuring incomplete, errors occurred!
See also "/source、code/AI/src/inference/OnnxRT/CppDeploy/samples/onnx_runtime_cpp/build/CMakeFiles/CMakeOutput.log".
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 1

ONNX Runtime inefence time

I use gpu, superglue and superpoint to reason for a long time, they are 837ms and 1234ms respectively. What's the matter? The inference time is loaded here
`auto start_time1 = std::chrono::steady_clock::now();
auto outputTensors = m_session.Run(Ort::RunOptions{nullptr}, m_inputNodeNames.data(), inputTensors.data(),
m_numInputs, m_outputNodeNames.data(), m_numOutputs);

auto end_time1 = std::chrono::steady_clock::now();
auto elapsed_time = std::chrono::duration_cast<std::chrono::microseconds>(end_time1 - start_time1).count();
std::cout << " Inference time: " << elapsed_time << " microseconds" << std::endl;`

pipline for superpoint

could you please show me the pipline about superpoint,I faced some problems when inferenced my superpoint.onnx.so I hope to get inspired from your code

ONNX Runtime inefence time

I use gpu, superglue and superpoint to reason for a long time, they are 837ms and 1234ms respectively. What's the matter? The inference time is loaded here
`auto start_time1 = std::chrono::steady_clock::now();
auto outputTensors = m_session.Run(Ort::RunOptions{nullptr}, m_inputNodeNames.data(), inputTensors.data(),
m_numInputs, m_outputNodeNames.data(), m_numOutputs);

auto end_time1 = std::chrono::steady_clock::now();
auto elapsed_time = std::chrono::duration_cast<std::chrono::microseconds>(end_time1 - start_time1).count();
std::cout << " Inference time: " << elapsed_time << " microseconds" << std::endl;`

[Help] how to add new inference engine?

Hi @xmba15 ,

I ported your code and use onnx runtime to inference model, for now I wanna use nvidia triton to inference some model.

So what's the best way to let project like this repo suppot both onnx and triton?

Does pimpl still a good choice for this situation?

I will be grateful for any help you can provide.

License?

Hi,
Please could you provide a LICENSE file detailing the license, e.g. MIT, you have applied to your code?
Thanks

About the loftr result

I have tested the loftr,but i find some problem, when i use two image which have same size , the result is normal,but when i use a big picture and a small picture ,it detect nothing!
image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.