diff --git a/onnxruntime/core/providers/cuda/cuda_fence.cc b/onnxruntime/core/providers/cuda/cuda_fence.cc index e5f7f6de8d..ce368a7daa 100644 --- a/onnxruntime/core/providers/cuda/cuda_fence.cc +++ b/onnxruntime/core/providers/cuda/cuda_fence.cc @@ -43,7 +43,8 @@ void CUDAFence::BeforeUsingAsOutput(onnxruntime::ProviderType provider_type, int } bool CUDAFence::CanRelease() { - return cudaEventQuery(read_event_) == cudaSuccess; + return cudaEventQuery(read_event_) == cudaSuccess && + cudaEventQuery(write_event_) == cudaSuccess; } void CUDAFence::AfterUsedAsInput(int queue_id) {