diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp index 19ce2c1844..97a33aaf1d 100644 --- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp +++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp @@ -1194,6 +1194,7 @@ bool Device::init() { selectDeviceByName = GPU_DEVICE_NAME; } + bool foundDevice = false; // Loop through all active devices and initialize the device info structure for (; ordinal < numDevices; ++ordinal) { // Create the GPU device object @@ -1204,11 +1205,15 @@ bool Device::init() { } if (result && ((nullptr == selectDeviceByName) || ('\0' == selectDeviceByName[0]) || (strstr(selectDeviceByName, d->info().name_) != nullptr))) { + foundDevice = true; d->registerDevice(); } else { delete d; } } + if (!foundDevice) { + Device::tearDown(); + } return true; }