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

How to Infer Data in Video Memory #18080

Closed
KunMengcode opened this issue Oct 24, 2023 · 2 comments
Closed

How to Infer Data in Video Memory #18080

KunMengcode opened this issue Oct 24, 2023 · 2 comments
Labels
ep:TensorRT issues related to TensorRT execution provider platform:windows issues related to the Windows platform

Comments

@KunMengcode
Copy link

KunMengcode commented Oct 24, 2023

Describe the issue

I used FFmpeg to pull the RTSP video stream, which uses hard decoding.
Now I will store the decoded YVU data in the Video memory (later I will process it into RGB), and I want to directly use my ONNX model to infer the RGB data in the Video memory.
I don't quite understand how to operate.

Platform

Windows

OS Version

10

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.13

ONNX Runtime API

C++

Architecture

X64

Execution Provider

TensorRT

@github-actions github-actions bot added ep:TensorRT issues related to TensorRT execution provider platform:windows issues related to the Windows platform labels Oct 24, 2023
@RyanUnderhill
Copy link
Member

If you're using C++ you want to do something like this (incomplete, but should convey the idea). You want the memory info to be cuda, and you want to create a tensor using the existing pointers (vs having Onnxruntime allocate it):

// Create Ort::MemoryInfo instance for GPU memory
Ort::MemoryInfo memory_info = Ort::MemoryInfo::Create("Cuda", OrtAllocatorType::OrtDeviceAllocator, 0, OrtMemType::OrtMemTypeDefault);

// Allocate memory on the GPU
float* input_data = (Your Cuda GPU allocated memory)

// Create tensor with pre-allocated GPU memory
// Note: this doesn't allocate memory, it just wraps the user-provided buffer in an OrtValue
Ort::Value input_tensor = Ort::Value::CreateTensor<float>(memory_info, input_data, input_tensor_size, input_shape.data(), input_shape.size());

@KunMengcode
Copy link
Author

Thank you for your answer,I think I roughly understand what you mean, and I will try it out in the coming period. And refine the example you provided to end the issue.
Based on your prompt, I have found other previous proposals that also illustrate this issue.
#11528
And code examples
https://github.com/microsoft/onnxruntime/blob/main/onnxruntime/test/shared_lib/test_inference.cc
(Download Find "USE_CUDA..." keywords)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:TensorRT issues related to TensorRT execution provider platform:windows issues related to the Windows platform
Projects
None yet
Development

No branches or pull requests

2 participants