[Fix] During shutdown, removing operations for device resources such as events and stream.

This commit is contained in:
wbigat
2023-04-10 15:38:18 +08:00
parent a4686c8a90
commit c180c88391
2 changed files with 2 additions and 12 deletions
+1 -8
View File
@@ -63,14 +63,7 @@ PyObject * THPModule_npu_shutdown(PyObject * /* unused */)
} catch (std::exception& e) {
NPU_LOGE("npuSynchronizeDevice failed err=:%s", e.what());
}
at_npu::native::GraphExecutor::GetInstance().Finalize();
at_npu::native::TdtChannelForPrint::GetInstance().Finalize();
THNPUCachingHostAllocator_emptyCache();
try {
c10_npu::NPUCachingAllocator::emptyCache();
} catch (std::exception& e) {
NPU_LOGE("NPUCachingAllocator::emptyCache failed err=:%s", e.what());
}
c10_npu::NpuSysCtrl::SysStatus status = c10_npu::NpuSysCtrl::GetInstance().Finalize();
if (status != c10_npu::NpuSysCtrl::SysStatus::FINALIZE_SUCC) {
fprintf(stdout, "THPModule_npu_shutdown failed.\n");
@@ -220,12 +220,9 @@ NpuSysCtrl::NpuSysCtrl() : init_flag_(false), device_id_(0) {}
}
this->RegisterReleaseFn([=]() ->void {
c10_npu::NPUEventManager::GetInstance().ClearEvent();
auto stream = c10_npu::getCurrentNPUStream();
(void)aclrtDestroyStream(stream);
C10_NPU_CHECK(ge::GEFinalize());
C10_NPU_CHECK(aclrtResetDevice(device_id_));
C10_NPU_CHECK(aclFinalize());
C10_NPU_CHECK(aclrtResetDevice(device_id_));
}, ReleasePriority::PriorityLast);
init_flag_ = false;