diff --git a/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp b/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp index bc9cb20466..3926c7eb41 100644 --- a/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp +++ b/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp @@ -512,15 +512,17 @@ bool Device::init() { } } - // Loop through all available devices - for (auto device1: Device::devices()) { - // Find all agents that can have access to the current device - for (auto agent: static_cast(device1)->p2pAgents()) { - // Find cl_device_id associated with the current agent - for (auto device2: Device::devices()) { - if (agent.handle == static_cast(device2)->getBackendDevice().handle) { - // Device2 can have access to device1 - device2->p2pDevices_.push_back(as_cl(device1)); + if (0 != Device::numDevices(CL_DEVICE_TYPE_GPU, false)) { + // Loop through all available devices + for (auto device1: Device::devices()) { + // Find all agents that can have access to the current device + for (auto agent: static_cast(device1)->p2pAgents()) { + // Find cl_device_id associated with the current agent + for (auto device2: Device::devices()) { + if (agent.handle == static_cast(device2)->getBackendDevice().handle) { + // Device2 can have access to device1 + device2->p2pDevices_.push_back(as_cl(device1)); + } } } }