Skip to content

Commit

Permalink
accelerator/cuda: Check for cuda devices
Browse files Browse the repository at this point in the history
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 <wilzhang@amazon.com>
  • Loading branch information
wckzhang committed Apr 25, 2023
1 parent da6d715 commit ae98e04
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion opal/mca/accelerator/cuda/accelerator_cuda_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,15 @@ static opal_accelerator_base_module_t* accelerator_cuda_init(void)
if (!opal_cuda_support) {
return NULL;
}

int count = 0;
/* If cuInit fails or there are no cuda capable devices, return NULL. */
if (cuInit(0)) {
return NULL;
}
CUresult ret = cuDeviceGetCount(&count);
if (ret || count == 0) {
return NULL;
}
opal_accelerator_cuda_delayed_init();
return &opal_accelerator_cuda_module;
}
Expand Down

0 comments on commit ae98e04

Please sign in to comment.