Skip to content

Commit bca4d9d

Browse files
committed
[SYCL][CUDA] Avoid failure when no devices available
`cuInit` fails when there are no CUDA devices, but this is not an error for the SYCL runtime. This patch converts the error into a platform with no devices. Signed-off-by: Ruyman Reyes <[email protected]>
1 parent 52c8ca5 commit bca4d9d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,13 @@ pi_result cuda_piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms,
545545
std::call_once(
546546
initFlag,
547547
[](pi_result &err) {
548-
err = PI_CHECK_ERROR(cuInit(0));
548+
CUresult cuErr = cuInit(0);
549+
if (cuErr == CUDA_ERROR_NO_DEVICE) {
550+
// The cuda backend is active, but there are no devices
551+
// available
552+
return;
553+
}
554+
err = check_error(cuErr, "cuInit", __LINE__, __FILE__);
549555

550556
int numDevices = 0;
551557
err = PI_CHECK_ERROR(cuDeviceGetCount(&numDevices));

0 commit comments

Comments
 (0)