diff --git a/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc b/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc index ed1f79e37b..58bceb4753 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc @@ -60,6 +60,8 @@ bool HcclContext::Finalize() { MS_LOG(ERROR) << "HcclComm destroy failed, ret:" << hccl_result; return false; } + MS_LOG(INFO) << "HcclComm destroy success"; + hccl_comm_ = nullptr; return true; } } // namespace kernel diff --git a/mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc b/mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc index 1a78623b6b..40bfb62e3c 100644 --- a/mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc +++ b/mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc @@ -261,6 +261,7 @@ void AscendKernelRuntime::ReleaseDeviceRes() { mem_manager_->FreeDeviceMemory(); } + (void)DestroySingleOpHccl(); (void)DestroyHccl(); (void)ResetDevice(); (void)ProfilingManager::GetInstance().StopProfiling(); @@ -762,11 +763,6 @@ bool AscendKernelRuntime::ResetDevice() { stream_ = nullptr; } - if (!DestroySingleOpHccl()) { - MS_LOG(ERROR) << "Destroy hccl failed"; - return false; - } - if (rt_context_ != nullptr) { auto ret = rtCtxDestroy(rt_context_); if (ret != RT_ERROR_NONE) { @@ -821,21 +817,10 @@ bool AscendKernelRuntime::HcclInit() { } bool AscendKernelRuntime::DestroySingleOpHccl() { - auto context_ptr = MsContext::GetInstance(); - MS_EXCEPTION_IF_NULL(context_ptr); - if (context_ptr->get_param(MS_CTX_EXECUTION_MODE) != kPynativeMode) { - return true; - } - if (!NeedDestroyHccl()) { - MS_LOG(INFO) << "Hccl is not enable, no need to close."; - return true; - } if (!kernel::HcclContext::GetInstance().Finalize()) { MS_LOG(ERROR) << "Hccl finalize failed"; return false; } - MS_LOG(INFO) << "Hccl destroy successful."; - context_ptr->set_param(MS_CTX_ENABLE_HCCL, false); return true; }