Skip to content

Commit fdf50d0

Browse files
authored
Merge pull request #11617 from wckzhang/cuda_check_device
accelerator/cuda: Check for cuda devices
2 parents f6674c0 + ae98e04 commit fdf50d0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

opal/mca/accelerator/cuda/accelerator_cuda_component.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,15 @@ static opal_accelerator_base_module_t* accelerator_cuda_init(void)
188188
if (!opal_cuda_support) {
189189
return NULL;
190190
}
191-
191+
int count = 0;
192+
/* If cuInit fails or there are no cuda capable devices, return NULL. */
193+
if (cuInit(0)) {
194+
return NULL;
195+
}
196+
CUresult ret = cuDeviceGetCount(&count);
197+
if (ret || count == 0) {
198+
return NULL;
199+
}
192200
opal_accelerator_cuda_delayed_init();
193201
return &opal_accelerator_cuda_module;
194202
}

0 commit comments

Comments
 (0)