Ask Your Question
0

Make GpuMat continuous / copy to continuous memory.

asked 2020-10-31 12:50:07 -0600

Maaike gravatar image

I am trying to copy GpuMat data to the Triton Inference Server shared memory. However, a GpuMat is not continuous, but the Inference Server expects continuous data. Downloading the gpuMat to a cv::Mat and then do a cudaMemcpy of the cv::Mat into the shared memory of the Inference server works, but I want to copy it to the gpu shared memory of the inference server without downloading it. But I'm struggling to find out how I should do that.

My input GpuMat is a 600x600 color image (3 layers) converted to float.

What is the data structure of the GpuMat and / or how to make it continuous or copy it so it becomes continuous?

I tried with cudaMemcpy2D, I tried just a cudaMemcpy but row by row, I tried to create a continuous gpumat with cv::cuda::createContinuous and then copyTo from the input to the continuous array.

edit retag flag offensive close merge delete

Comments

I’ll think about it some. Anyway, the word you’re looking for is contiguous.

sjhalayka gravatar imagesjhalayka ( 2020-10-31 13:50:00 -0600 )edit

Thanks.

Yes, well, I searched for continuous but if I search for contiguous I do not get other results. But indeed, that's what's needed, but it might be very specific or so because I don't find a lot about it.

Maaike gravatar imageMaaike ( 2020-11-01 05:39:14 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2020-11-03 06:03:35 -0600

Maaike gravatar image

It turns out that it works perfectly with cudaMemcpy2D, as long as you don't make the image contiguous where you expect it to be not contiguous. Oops. So cudaMemcpy2D does exactly what we thought it would do.

You should use the step from GpuMat as the source pitch value. Destination pitch should be the width of the image (because there is no additional spacing in a continuous image). I assume width and height are clear. src can be gpuMat.data or gpuMat.ptr(0), as far as I can see.

edit flag offensive delete link more

Comments

Nice job!!

sjhalayka gravatar imagesjhalayka ( 2020-11-03 09:29:07 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-10-31 12:50:07 -0600

Seen: 1,567 times

Last updated: Nov 03 '20