Skip to content

Commit 48ddb53

Browse files
authored
Merge pull request opencv#18386 from JulienMaille:patch-1
* Make sure there is a cuda device before getting it * Update init.hpp
1 parent f584c6d commit 48ddb53

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/dnn/src/cuda4dnn/init.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ namespace cv { namespace dnn { namespace cuda4dnn {
5757

5858
bool isDeviceCompatible()
5959
{
60+
if (getDeviceCount() <= 0)
61+
return false;
62+
6063
int device_id = getDevice();
6164
if (device_id < 0)
6265
return false;
@@ -77,6 +80,9 @@ namespace cv { namespace dnn { namespace cuda4dnn {
7780

7881
bool doesDeviceSupportFP16()
7982
{
83+
if (getDeviceCount() <= 0)
84+
return false;
85+
8086
int device_id = getDevice();
8187
if (device_id < 0)
8288
return false;

0 commit comments

Comments
 (0)