"illegal memory access" when calling cv::cuda::ORB::detectAndComputeAsync() from multiple threads

asked 2017-07-08 00:59:54 -0500

jrussino gravatar image

I'm trying to run multiple threads (std::thread), each of which opens a VideoCapture on a different device, captures frames, uploads them to the GPU, and computes ORB features & descriptors. If I run more than one thread the program fails on the call to detectAndComputeAsync. The exact error message is not consistent; on each run I see one of ~9 different errors, almost all of which include "an illegal memory access was encountered".

I've posted the (simplest version of the) offending code here:


I also pasted each variant of error message that I observed into comment below that code snippet.


  • I'm using a different cuda::Stream for each thread's CUDA operations.
  • This runs without error if I comment out the call to detectAndComputeAsync on line 49.
  • This runs without error If I only run one thread (i.e. comment out lines 66 and 70).
edit retag flag offensive close merge delete


"I'm trying to run multiple threads " -- don't.

what made you think, any of it would be thread-safe ?

berak gravatar imageberak ( 2017-07-08 01:02:31 -0500 )edit

So then how is detectAndComputeAsync supposed to be used (or any of the asynchronous CUDA methods)? I've never seen an example of cv::Feature2DAsync in use, so if somebody has a non-trivial working example that would be immensely helpful. In what sense can this method be called asynchronously?

jrussino gravatar imagejrussino ( 2017-07-08 23:10:03 -0500 )edit