From 7b577b92e04ff3ac62eefe2837f90eb4d266b413 Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Tue, 4 Sep 2018 11:27:24 +0800 Subject: [PATCH] fix a memory bug in CudnnHolder --- paddle/fluid/platform/device_context.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/paddle/fluid/platform/device_context.cc b/paddle/fluid/platform/device_context.cc index 3ec20ad7e5b..c6f1d1f3d54 100644 --- a/paddle/fluid/platform/device_context.cc +++ b/paddle/fluid/platform/device_context.cc @@ -176,13 +176,12 @@ class CudnnHolder { if (required_workspace_len <= workspace_len_) { return; } - void* new_workspace = paddle::memory::Alloc(place_, required_workspace_len); if (workspace_ != nullptr) { // Maybe someone is using the current workspace PADDLE_ENFORCE(cudaStreamSynchronize(*stream_)); paddle::memory::Free(place_, workspace_); } - workspace_ = new_workspace; + workspace_ = paddle::memory::Alloc(place_, required_workspace_len); workspace_len_ = required_workspace_len; } -- GitLab