[Fix] During shutdown, removing operations for device resources such as events and stream.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user