diff --git a/hipamd/src/hip_stream.cpp b/hipamd/src/hip_stream.cpp index c8ff4bd269..e8e286bfb6 100644 --- a/hipamd/src/hip_stream.cpp +++ b/hipamd/src/hip_stream.cpp @@ -534,8 +534,15 @@ hipError_t hipStreamWaitEvent_common(hipStream_t stream, hipEvent_t event, unsig } hip::Stream* waitStream = reinterpret_cast(stream); hip::Event* e = reinterpret_cast(event); - hip::Stream* eventStream = reinterpret_cast(e->GetCaptureStream()); + auto eventStreamHandle = reinterpret_cast(e->GetCaptureStream()); + // the stream associated with the device might have been destroyed + if (!hip::isValid(eventStreamHandle)) { + // Stream associated with the event has been released + // meaning the event has been completed and we can resume the current stream + return hipSuccess; + } + hip::Stream* eventStream = reinterpret_cast(eventStreamHandle); if (eventStream != nullptr && eventStream->IsEventCaptured(event) == true) { ClPrint(amd::LOG_INFO, amd::LOG_API, "[hipGraph] Current capture node StreamWaitEvent on stream : %p, Event %p", stream,