forked from mindspore-Ecosystem/mindspore
!1680 fix resource release bug of memory swap
Merge pull request !1680 from zyli2020/r0.3
This commit is contained in:
commit
527f1d70ce
|
@ -104,10 +104,15 @@ void GPUKernelRuntime::ReleaseDeviceRes() {
|
|||
}
|
||||
CHECK_OP_RET_WITH_EXCEPT(GpuBufferMgr::GetInstance().Destroy(), "Could not destroy gpu data queue.");
|
||||
}
|
||||
|
||||
// destroy remaining memory swap events and free host memory
|
||||
if (mem_swap_manager_->trigger_swap()) {
|
||||
mem_swap_manager_->ClearSwapQueue();
|
||||
mem_swap_manager_->ReleaseHostPinnedMem();
|
||||
for (auto &item : mem_swap_map_) {
|
||||
auto &mem_swap_manager = item.second;
|
||||
MS_EXCEPTION_IF_NULL(mem_swap_manager);
|
||||
if (mem_swap_manager->trigger_swap()) {
|
||||
mem_swap_manager->ClearSwapQueue();
|
||||
mem_swap_manager->ReleaseHostPinnedMem();
|
||||
}
|
||||
}
|
||||
|
||||
GPUDeviceManager::GetInstance().ReleaseDevice();
|
||||
|
@ -146,6 +151,7 @@ bool GPUKernelRuntime::Run(session::KernelGraph *graph) {
|
|||
iter = mem_swap_map_.emplace(graph, std::make_shared<MemSwapManager>(gpu_mem_copy_manager)).first;
|
||||
}
|
||||
mem_swap_manager_ = iter->second;
|
||||
MS_EXCEPTION_IF_NULL(mem_swap_manager_);
|
||||
struct timeval start_time, end_time;
|
||||
(void)gettimeofday(&start_time, nullptr);
|
||||
if (is_enable_dynamic_mem && !is_enable_pynative_infer) {
|
||||
|
|
Loading…
Reference in New Issue