segfault with multithreaded gpu calls

asked 2014-08-26 16:15:19 -0600

stfn gravatar image

updated 2020-11-06 15:34:47 -0600

Hey,

I'm using gpu::HOGDescriptor from OpenCV 2.4.9.0 in a multithreaded application, that is multiple gpu HoGs are running simultaneously. Ocassionally, I get the following error:

OpenCV Error: Gpu API call (an illegal memory access was encountered) in extract_descrs_by_cols, file /home/stfn/libs/opencv-2.4.9/modules/gpu/src/cuda/hog.cu, line 545
OpenCV Error: Gpu API call (an illegal memory access was encountered) in mallocPitch, file /home/stfn/libs/opencv-2.4.9/modules/dynamicuda/include/opencv2/dynamicuda/dynamicuda.hpp, line 1134
OpenCV Error: Gpu API call (an illegal memory access was encountered) in normalize_hists, file /home/stfn/libs/opencv-2.4.9/modules/gpu/src/cuda/hog.cu, line 323
OpenCV Error: Gpu API call (an illegal memory access was encountered) in call, file /home/stfn/libs/opencv-2.4.9/modules/gpu/include/opencv2/gpu/device/detail/transform_detail.hpp, line 364
terminate called recursively
terminate called recursively
terminate called after throwing an instance of 'cv::ExceptionAbgebrochen (Speicherabzug geschrieben)

It seems that there is no rule for that, it happens completely randomly. Is there a guideline on Cuda resp. the OpenCV gpu module in multithreaded applications or stuff?

edit retag flag offensive close merge delete

Comments

It is known that OpenCV CUDA functionality is not threadsafe ... this is a large downside but this causes the illegal attempts you are getting.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-27 08:01:14 -0600 )edit

So ... would it help to create a cuda context in each thread? The data processed is independent for each thread.

stfn gravatar imagestfn ( 2014-08-27 17:33:55 -0600 )edit

That could be the solution, I am not experienced enough in CUDA development to help you out here.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-28 04:22:42 -0600 )edit

@stfn: Hello. Did you find a solution to your problem? I am facing the same occasional error with opencv 3.0.0 with cuda::HOG (in compute() function) in a multi-threading software. Thanks.

Gabriele D gravatar imageGabriele D ( 2015-10-22 04:01:21 -0600 )edit

Like I said, CUDA is not my main area of research, so experience is quite limited there :)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-22 04:04:26 -0600 )edit

Any news for version 2.4.13.2 ?

zen gravatar imagezen ( 2017-02-09 09:04:32 -0600 )edit