Ask Your Question
0

Using Streams with functions like meanStdDev?

asked 2019-03-01 12:26:22 -0500

updated 2019-03-01 13:26:39 -0500

I am attempting to use a cv::cuda::Stream (per thread) to do opencv cuda operations on images from multiple threads. Most functions take an optional Stream parameter, but some do not, like cv::cuda::meanStdDev. I find that if i call meanStdDev while the other (cv::cuda) calls are given a stream. I get a crash.

How would I be able to use a function like meanStdDev in my processing pipeline when using streams?

Thanks, -Ryan

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-03-04 04:03:32 -0500

updated 2019-03-04 11:22:56 -0500

Hi, that specific function uses the NVIDIA npp's, which previous to CUDA 10.1 don't seem to properly support streaming, according to the documentation, NVIDIA (see the bottom post), and an issue directly related to the meanStdDev function.

Previously, the stream context was "the only state NPP remembers between function calls" meaning that there could be only one active stream at any one time. You could therefore only switch streams and not use multiple streams concurrently. It looks like this has been changed in CUDA 10, but OpenCV has not been updated yet to include this change.

edit flag offensive delete link more

Comments

What about for functions minMax and GpuMat::setTo, they dont have function overloads that take streams either?

I have a set of processing that I have running on images that include these non streamable functions. If I create a stream per thread and try to process multiple image at the same time (say one per thread, passing the thread's associated stream to the cuda opencv functions that take one), i seem to be getting a crash when i get to a function (like cv::cuda::minMax) that doesnt have an overload that accepts a stream, is that expected?

I need to use reduction operations like minMax in my pipeline, is there any way to have an image processing pipeline where one could use such functions that can run concurrently?

Thanks, Ryan

ender1618 gravatar imageender1618 ( 2019-03-04 10:35:32 -0500 )edit

Which version of OpenCV are you using? meanStdDev takes cuda streams, although from what I have said above this will not work correctly if you are issuing commands from multiple threads to different streams because it uses npp. You can test it on your system by running

opencv_test_cudaarithm.exe" --gtest_filter=CUDA_Arithm/MeanStdDev.Async/0

minMax also takes streams but the function is called findMinMax, you can test with

opencv_test_cudaarithm.exe" --gtest_filter=CUDA_Arithm/MinMaxLoc.Async/0
cudawarped gravatar imagecudawarped ( 2019-03-04 11:30:25 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-03-01 12:26:22 -0500

Seen: 253 times

Last updated: Mar 04 '19