Skip to content

Add TensorRT support #6212

Open
Open

Description

@turowicz

Is your feature request related to a problem? Please describe.
Currently the fastest way of executing models for Computer Vision inference is by running a TensorRT-optimised model. It is widely available in C/C++ but you cannot really use it in C#.

Describe the solution you'd like
I would like to be able to load the TensorRT engine into C# memory and call it from there using OpenCVSharp's Mat structures.

Describe alternatives you've considered
We are currently using Triton Inference Server but it adds overhead time for data serialisation and transmission.

Additional context
There are certain scenarios that would benefit greatly from calling a TensorRT model in-process such as Quality Control.

Activity

  1. ghost added
    untriagedNew issue has not been triaged
    on Jun 1, 2022
  2. luisquintanilla commented on Jun 10, 2022

    @luisquintanilla
    Contributor

    Hi @turowicz

    ML.NET offers the ability to export models to ONNX which from my understanding is one of the supported frameworks.

    To export an ML.NET model to ONNX you use the ConvertToOnnx transform.

    Here's additional documentation on how to do it as well.

    https://docs.microsoft.com/dotnet/machine-learning/how-to-guides/save-load-machine-learning-models-ml-net#save-an-onnx-model-locally

    Does that satisfy your requirements?

  3. turowicz commented on Jun 13, 2022

    @turowicz
    Author

    I meant the other way round. Load up a TRT model in ML.NET and infer on data.

  4. michaelgsharp commented on Jun 13, 2022

    @michaelgsharp
    Contributor

    What model format are you thinking? Still onxx? and it sounds a large part of the ask is having a way to not have to copy the data, is that correct?

  5. turowicz commented on Jun 13, 2022

    @turowicz
    Author

    Model format: TensorRT by NVIDIA

  6. turowicz commented on Jun 13, 2022

    @turowicz
    Author

    Load it in C#, run inference. This requires C# externs for TensorRT C runtime

  7. changed the title [-]TensorRT support[/-] [+]Add TensorRT support[/+] on Jul 11, 2022
  8. added and removed
    untriagedNew issue has not been triaged
    needs-further-triageNeeds deeper review after initial triage
    on Jul 11, 2022
  9. michaelgsharp commented on Jul 11, 2022

    @michaelgsharp
    Contributor

    @luisquintanilla I'll mark this as future for now, but we need to figure out if this aligns with our goals and if so when we would be able to take a look at this.

  10. added this to the ML.NET Future milestone on Jul 11, 2022
  11. lorenzo-park commented on Feb 10, 2025

    @lorenzo-park

    Hi, by any chance, is it possible to make the priority of this feature higher? AFIK, the current available option to serve pytorch-trained models in C# is to convert them in ONNX format, howver, converting pytorch-trained models is getting harder in these days. The model authors seems getting less care about ONNX-compatibility these days. I think this is because the pytorch community is introducing the compilation features for Pytorch such as TorchDynamo and Torch-TensorRT. and it removes the necessity of the ONNX as an intermediate artifact to optimize their model for their accelerators. So I thought it is time to consider TensorRT runtime as one of the alternatives of onnxruntime?

    (Writing during struggling to convert some open weight to ONNX format...)

  12. added
    Priority:3Work that is nice to have
    area-ONNXONNX model export and inference
    and removed on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:3Work that is nice to havearea-ONNXONNX model export and inferenceenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions