diff --git a/modules/dnn/src/cuda4dnn/init.hpp b/modules/dnn/src/cuda4dnn/init.hpp index b548f0958a..e9d997311f 100644 --- a/modules/dnn/src/cuda4dnn/init.hpp +++ b/modules/dnn/src/cuda4dnn/init.hpp @@ -57,6 +57,9 @@ namespace cv { namespace dnn { namespace cuda4dnn { bool isDeviceCompatible() { + if (getDeviceCount() <= 0) + return false; + int device_id = getDevice(); if (device_id < 0) return false; @@ -77,6 +80,9 @@ namespace cv { namespace dnn { namespace cuda4dnn { bool doesDeviceSupportFP16() { + if (getDeviceCount() <= 0) + return false; + int device_id = getDevice(); if (device_id < 0) return false;