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

G-API: Support CUDA & TensoRT Execution Providers for ONNXRT Backend #24059

Merged

Conversation

TolyaTalamanov
Copy link
Contributor

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@TolyaTalamanov TolyaTalamanov added this to the 4.9.0 milestone Jul 26, 2023
@TolyaTalamanov TolyaTalamanov changed the title G-API: Support CUDA & TensoRT Execution Providers for ONNXRT Backend WIP: G-API: Support CUDA & TensoRT Execution Providers for ONNXRT Backend Jul 26, 2023
@TolyaTalamanov TolyaTalamanov force-pushed the at/add-onnx-cuda-execution-provider branch from 156248b to 42b5fa2 Compare July 26, 2023 11:56
@TolyaTalamanov
Copy link
Contributor Author

Based on this PR:
#24045

modules/gapi/include/opencv2/gapi/infer/onnx.hpp Outdated Show resolved Hide resolved
modules/gapi/include/opencv2/gapi/infer/onnx.hpp Outdated Show resolved Hide resolved
modules/gapi/include/opencv2/gapi/infer/onnx.hpp Outdated Show resolved Hide resolved
static void addTensorRTExecutionProvider(Ort::SessionOptions *session_options,
const cv::gapi::onnx::ep::TensorRT &trt_ep) {
OrtTensorRTProviderOptions options{};
options.device_id = trt_ep.device_id;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider more options:

options.trt_max_workspace_size = 2147483648;
options.trt_max_partition_iterations = 10;
options.trt_min_subgraph_size = 5;
options.trt_fp16_enable = 1;
options.trt_engine_cache_enable = 1;
options.trt_engine_cache_path = "ort_tensorrt_cache";
options.trt_dump_subgraphs = 1;  

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well technically they can be provided via env variable:
https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html#execution-provider-options

Not clear at this point which of them is important to expose to API

@TolyaTalamanov TolyaTalamanov changed the title WIP: G-API: Support CUDA & TensoRT Execution Providers for ONNXRT Backend G-API: Support CUDA & TensoRT Execution Providers for ONNXRT Backend Jul 26, 2023
@TolyaTalamanov TolyaTalamanov force-pushed the at/add-onnx-cuda-execution-provider branch from f2860d7 to 84e29ef Compare July 26, 2023 14:06
@TolyaTalamanov
Copy link
Contributor Author

@asmorkalov We're ready to merge this

@asmorkalov asmorkalov merged commit f46f7ef into opencv:4.x Aug 2, 2023
23 checks passed
@asmorkalov asmorkalov mentioned this pull request Aug 7, 2023
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
…execution-provider

G-API: Support CUDA & TensoRT Execution Providers for ONNXRT Backend opencv#24059

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [ ] I agree to contribute to the project under Apache 2 License.
- [ ] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants