Repository: opencv
Issue: CUDA exceptions in OpenCV GPU module in multi-threaded version
Labels: bug,auto-transferred,priority: normal,affected: 2.4,category: gpu/cuda (contrib)

Transferred from http://code.opencv.org/issues/3738

```
|| T Abdullah on 2014-06-04 16:05
|| Priority: Normal
|| Affected: 2.4.0 - 2.4.8
|| Category: gpu (cuda)
|| Tracker: Bug
|| Difficulty: 
|| PR: 
|| Platform: x64 / Windows
```
## CUDA exceptions in OpenCV GPU module in multi-threaded version

```
Hi,
Dear all,

I am trying to run a multi-threaded application using OpenCV GPU module. The application is developed in Visual Studio 2012 professionl + CUDA 5.5 + OpenCV 2.4.6 and uses pthreads for multi-threading. I built OpenCV 2.4.6 for this environment.

My application executes with two threads and there are no exceptions. I start getting a number of CUDA related exceptions with 3 or more that three threads. Single application of multiple application instances. It does not matter 
am observing the same behavior.

OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=4, file=C:/opencv-2.4.6/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu, line=1306) in unknown function, file C:\opencv-2.4.6\modules\gpu\src\cascadeclassifier.cpp, line 173

OpenCV Error: Gpu API call (unspecified launch failure) in unknown function, file C:\opencv-2.4.6\modules\core\src\gpumat.cpp, line 1196

OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=4, file=C:/opencv-2.4.6/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu, line=1306) in unknown function, file C:\opencv-2.4.6\modules\gpu\src\cascadeclassifier.cpp, line 173

OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=4, file=C:/opencv-2.4.6/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu, line=1523) in unknown function, file C:\opencv-2.4.6\modules\gpu\src\cascadeclassifier.cpp, line 173

OpenCV Error: Gpu API call (unspecified launch failure) in unknown function, file C:\opencv-2.4.6\modules\core\src\gpumat.cpp, line 1415

OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=4, file=C:/opencv-2.4.6/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu, line=1523) in unknown function, file C:\opencv-2.4.6\modules\gpu\src\cascadeclassifier.cpp, line 173

OpenCV Error: Gpu API call (NCV Assertion Failed: retcode=2, file=C:/opencv-2.4.6/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu, line=1768) in unknown function, file C:\opencv-2.4.6\modules\gpu\src\cascadeclassifier.cpp, line 173

OpenCV Error: Gpu API call (NCV Assertion Failed: retcode=5, file=C:/opencv-2.4.6/modules/gpu/src/nvidia/NCVHaarObjectDetection.cu, line=1575) in unknown function, file C:\opencv-2.4.6\modules\gpu\src\cascadeclassifier.cpp, line 173


I can provide more details if needed.

I would also welcome any alternate suggestions for solving these exceptions  as requested by me in this thread. [http://answers.opencv.org/question/34578/best-practices-for-opencv-gpu-module-in-multi/]
```
## History
##### Alexander Karsakov on 2014-06-09 14:04

```
Vlad, could you please take a look?
-   Assignee set to Vladislav Vinogradov
-   Status changed from New to Open
-   Category set to gpu (cuda)
```
##### T Abdullah on 2014-07-11 16:46

```
Hi Vladislav/alexander,

It has been more than a month after submitting the issue. I am still facing the crash. I can provide more details if needed to solve my problem.


Regards,
Tariq Abdullah
```