Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 7.1
• JetPack Version (valid for Jetson only)
• TensorRT Version 10.6
• NVIDIA GPU Driver Version (valid for GPU only) 560.30.35
• Issue Type( questions, new requirements, bugs) Questions
After DeepStream-App decoding frames and infering bboxes, I need to run custom cnn models with those frames and bboxes.
Raw frames are in GPU and input patches of custom cnn model needed to be in gpu mem. However I don’t want to do unnecessary memory copy gpu->cpu , cpu->gpu.
So, I am trying access frame data directly through NvBufSurface.
I checked that
- EglImage supported by NVBUF_MEM_SURFACE_ARRAY only.
- To access data point,
NvBufSurfaceMap
requires. - Only
NVBUF_MEM_CUDA_UNIFIED
supportsNvBufSurfaceMap
for dGPU. - The Color type of raw frame is
NVBUF_COLOR_FORMAT_NV12_709
.
I want to crop patches, resize, change color foramt to BGR without mem copy.
// cv::Mat nv12_mat = cv::Mat(height * 3 / 2, width, CV_8UC1, surface->surfaceList[frame_meta->batch_id].mappedAddr.addr[0], surface->surfaceList[frame_meta->batch_id].pitch);
// cv::Mat rgba_mat;
// cv::cvtColor(nv12_mat, rgba_mat, cv::COLOR_YUV2BGRA_NV12);
// mat_vector->push_back(nv12_mat);
copying cpu<-> gpu takes too much cpu usage. ( all cores were 99% in my case)
I read few posts in forums, they said use CUDA stream or cv::cuda::GpuMat or something…
I tried… but it didn’t work well.
cv::cuda::GpuMat nv12_mat = cv::cuda::GpuMat(height * 3 / 2, width, CV_8UC1, surface->surfaceList[frame_meta->batch_id].mappedAddr.addr[0], surface->surfaceList[frame_meta->batch_id].pitch);
cv::cuda::GpuMat rgb_mat;
cv::cuda::cvtColor(nv12_mat, rgb_mat, cv::COLOR_YUV2RGB_NV12);
Is there any efficient way to access frame data in gpu memory that I can crop/resize and feed them to tensorrt engine ?
Thank you.