diff --git a/hipamd/api/hip/hip_platform.cpp b/hipamd/api/hip/hip_platform.cpp index 1aa356cd36..c91199c077 100644 --- a/hipamd/api/hip/hip_platform.cpp +++ b/hipamd/api/hip/hip_platform.cpp @@ -569,6 +569,9 @@ extern "C" hipError_t hipLaunchKernel(const void *hostFunction, stream); int deviceId = ihipGetDevice(); + if (deviceId == -1) { + HIP_RETURN(hipErrorNoDevice); + } hipFunction_t func = PlatformState::instance().getFunc(hostFunction, deviceId); if (func == nullptr) { HIP_RETURN(hipErrorInvalidDeviceFunction);