crash on calling meanStdDev with stream?

asked 2019-03-05 14:53:31 -0600

I am attempting to use a cv::cuda::Stream thread per processing thread in my image processing pipeline. Essentially an image is processed by a thread, where i can have n threads and thus n images processed in parallel. (In my current tests i am only using 1 or 2 threads though).

Each call to cv::cuda functions is being passed its thread's cuda stream. Everything seems to be working until I get to a call to cv::cuda::meanStdDev (the version that takes a stream). I get a crash, something to do with a kernel execution failure.

If i change nothing other than passing those same stream overloaded cv::cuda functions cv::cuda::Stream::Null() as the stream, cv::cuda::meanStdDev does not crash, and gives the right answer.

This is how i am calling the function and interpreting its output.

  double vals[2];
  cv::cuda::HostMem mean_std_hm;
  cvc::meanStdDev(out_gimg, mean_std_hm, m_GpuStream);  
  m_GpuStream.waitForCompletion();
  mean_std_hm.createMatHeader().copyTo(cv::Mat(1, 2, CV_64FC1, &vals[0]));
  double mean = vals[0];
  double stdDev = vals[1];

I checked and both calls (crashing and non-crashing calls) are getting the same image...

Any Ideas as to what might be going wrong?

I am using OpenCv 3.4.3 with the CUDA compilation flag turned on.

Thanks, -Ryan

edit retag flag offensive close merge delete

Comments

Hi, if you tell me what was unclear about my previous answer, I will try to explain it in a different way? What I was trying to explain was that, if you manage to get meanStdDev to return without errors when using streams other than the default, the current NPP implementation (pre CUDA 10.1) only works on one stream at once. This means you can only switch streams and not use multiple streams at the same time, which seems to defeat the purpose of using different streams (if you go to the links I previously posted, you can see NVidia have commented on this oversight). This also means that it won't work if you want to issue CUDA calls to different streams in different threads.

cudawarped gravatar imagecudawarped ( 2019-03-06 04:51:55 -0600 )edit