From 03eee3092f5084fd58b97cba8d1734db2f29022b Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Wed, 20 May 2020 04:22:46 +0300 Subject: [PATCH] Memory leak fix --- src/layer.c | 2 +- src/parser.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layer.c b/src/layer.c index 026d58e9..a459f9d0 100644 --- a/src/layer.c +++ b/src/layer.c @@ -193,7 +193,7 @@ void free_layer_custom(layer l, int keep_cudnn_desc) if (l.output_avg_gpu) cuda_free(l.output_avg_gpu), l.output_avg_gpu = NULL; if (l.activation_input_gpu) cuda_free(l.activation_input_gpu), l.activation_input_gpu = NULL; } - if (l.delta_gpu && l.keep_delta_gpu && l.optimized_memory < 3) cuda_free(l.delta_gpu), l.delta_gpu = NULL; + if (l.delta_gpu && (l.optimized_memory < 1 || l.keep_delta_gpu && l.optimized_memory < 3)) cuda_free(l.delta_gpu), l.delta_gpu = NULL; if (l.rand_gpu) cuda_free(l.rand_gpu); if (l.squared_gpu) cuda_free(l.squared_gpu); if (l.norms_gpu) cuda_free(l.norms_gpu); diff --git a/src/parser.c b/src/parser.c index c94f4c78..2863388a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1457,9 +1457,9 @@ network parse_network_cfg_custom(char *filename, int batch, int time_steps) #ifdef GPU // futher GPU-memory optimization: net.optimized_memory == 2 + l.optimized_memory = net.optimized_memory; if (net.optimized_memory >= 2 && params.train && l.type != DROPOUT) { - l.optimized_memory = net.optimized_memory; if (l.output_gpu) { cuda_free(l.output_gpu); //l.output_gpu = cuda_make_array_pinned(l.output, l.batch*l.outputs); // l.steps