SURF_GPU & thread safety (Bug #3591)
Description
When multiple threads call SURF_GPU at the same time, they lead to unexpected and random results. It does not happen if each call is performed sequentially.
The bug seems to come from the operator() because it does not occur anymore if operator call is surrounded by mutex.
Exemple : --------------
| KO Thread code |--------------
[...]
cv::gpu::SURF_GPU surf(minHessian, 4, 2, is_extended, 0.01f);
surf(gpu_object, cv::gpu::GpuMat(), gpu_keypoints_object, gpu_descriptors_object);
surf(gpu_scene, cv::gpu::GpuMat(), gpu_keypoints_scene, gpu_descriptors_scene);
[...]
--------------
| OK Thread code |--------------
[...]
cv::gpu::SURF_GPU surf(minHessian, 4, 2, is_extended, 0.01f);
pthread_mutex_lock(mutex);
surf(gpu_object, cv::gpu::GpuMat(), gpu_keypoints_object, gpu_descriptors_object);
surf(gpu_scene, cv::gpu::GpuMat(), gpu_keypoints_scene, gpu_descriptors_scene);
pthread_mutex_unlock(mutex);
[...]
I'm working on Ubuntu 12.04.4 LTS 64bits with CUDA 5.5.22 (GPU Quadro K4000) and OpenCV 2.4.8 (Linux release version).
It does not seem to come from CUDA or GPU since I test with other gpu functions and I never encountered the problem again.
Associated revisions
Merge pull request #3591 from ilya-lavrenov:sse_avx
History
Updated by Stephane LADEVIE about 11 years ago
- Status changed from New to Cancelled
Updated by Vladislav Vinogradov about 11 years ago
Hello Stephane,
It is a known issue. SURF_GPU (+ some other GPU algorithms) are not thread safe.
It is mentioned in documentation for gpu::Stream
(http://docs.opencv.org/2.4.8/modules/gpu/doc/data_structures.html#gpu-stream), but also relates to multi-threading.
Updated by Stephane LADEVIE about 11 years ago
Oh, shame on me. I had totally missed gpu::Stream documentation.
Thanks for the reply !