From 7e2fffb194003a3338385c9ed4047361a3e01b68 Mon Sep 17 00:00:00 2001 From: Anatoly Baksheev Date: Sat, 6 Aug 2011 09:59:51 +0000 Subject: [PATCH] ticket #1280 --- modules/gpu/src/initialization.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/gpu/src/initialization.cpp b/modules/gpu/src/initialization.cpp index 84da515513..b13c173a36 100644 --- a/modules/gpu/src/initialization.cpp +++ b/modules/gpu/src/initialization.cpp @@ -177,8 +177,16 @@ void cv::gpu::DeviceInfo::queryMemory(size_t&, size_t&) const { throw_nogpu(); } int cv::gpu::getCudaEnabledDeviceCount() { int count; - cudaSafeCall( cudaGetDeviceCount( &count ) ); - return count; + cudaError_t error = cudaGetDeviceCount( &count ); + + if (error == cudaErrorInsufficientDriver) + return -1; + + if (error == cudaErrorNoDevice) + return 0; + + cudaSafeCall(error); + return count; }