Skip to content

Commit c836ff6

Browse files
authored
Merge pull request #1866 from kbenzie/benie/handle-cuInit-error-no-device
Handle CUDA_ERROR_NO_DEVICE returned from cuInit()
2 parents 7e38af7 + c5c0944 commit c836ff6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/adapters/cuda/platform.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ urPlatformGet(ur_adapter_handle_t *, uint32_t, uint32_t NumEntries,
6969
std::call_once(
7070
InitFlag,
7171
[](ur_result_t &Result) {
72-
UR_CHECK_ERROR(cuInit(0));
72+
CUresult InitResult = cuInit(0);
73+
if (InitResult == CUDA_ERROR_NO_DEVICE) {
74+
return; // No devices found which is not an error so exit early.
75+
}
76+
UR_CHECK_ERROR(InitResult);
7377
int NumDevices = 0;
7478
UR_CHECK_ERROR(cuDeviceGetCount(&NumDevices));
7579
try {

0 commit comments

Comments
 (0)