Browse Source

!9410 Hccl resource release

From: @jojobugfree
Reviewed-by: @kisnwang,@jjfeing
Signed-off-by: @jjfeing
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
92d8d3af47
2 changed files with 3 additions and 16 deletions
  1. +2
    -0
      mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc
  2. +1
    -16
      mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc

+ 2
- 0
mindspore/ccsrc/backend/kernel_compiler/hccl/hccl_context.cc View File

@@ -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


+ 1
- 16
mindspore/ccsrc/runtime/device/ascend/ascend_kernel_runtime.cc View File

@@ -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<int>(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<bool>(MS_CTX_ENABLE_HCCL, false);
return true;
}



Loading…
Cancel
Save