Skip to content

Commit ae98e04

Browse files
committed
accelerator/cuda: Check for cuda devices
Adds a check during component initialization for cuda capable devices. Does not select the component if no cuda capable devices are detected. Signed-off-by: William Zhang <[email protected]>
1 parent da6d715 commit ae98e04

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)