From b030ac0433768b2e9eef1e53849a7a719023db6f Mon Sep 17 00:00:00 2001 From: Mathieu Barnachon Date: Mon, 8 Feb 2016 13:17:08 +0100 Subject: [PATCH] Ensure the Cuda context is initialized correctly as long as the setDevice is not called in a multi-thread environment. --- modules/core/src/cuda_info.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/core/src/cuda_info.cpp b/modules/core/src/cuda_info.cpp index 5ad33ce8a1..08013ca988 100644 --- a/modules/core/src/cuda_info.cpp +++ b/modules/core/src/cuda_info.cpp @@ -70,6 +70,7 @@ void cv::cuda::setDevice(int device) (void) device; throw_no_cuda(); #else + cudaFree(0); cudaSafeCall( cudaSetDevice(device) ); #endif }