From 5996700bb8d234692d9cc4771ebb8d5f41f4b393 Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Mon, 9 Aug 2021 23:34:36 +0800 Subject: [PATCH] fix memory leak (#388) --- ppgan/datasets/base_dataset.py | 6 +++--- ppgan/datasets/builder.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ppgan/datasets/base_dataset.py b/ppgan/datasets/base_dataset.py index 8ea7b8b..229c8e2 100644 --- a/ppgan/datasets/base_dataset.py +++ b/ppgan/datasets/base_dataset.py @@ -13,10 +13,10 @@ # limitations under the License. import os +import copy from pathlib import Path -from abc import ABCMeta, abstractmethod - from paddle.io import Dataset +from abc import ABCMeta, abstractmethod from .preprocess import build_preprocess @@ -119,7 +119,7 @@ class BaseDataset(Dataset, metaclass=ABCMeta): return samples def __getitem__(self, idx): - datas = self.data_infos[idx] + datas = copy.deepcopy(self.data_infos[idx]) if hasattr(self, 'preprocess') and self.preprocess: datas = self.preprocess(datas) diff --git a/ppgan/datasets/builder.py b/ppgan/datasets/builder.py index 2e1bfb9..9ee1f41 100644 --- a/ppgan/datasets/builder.py +++ b/ppgan/datasets/builder.py @@ -62,7 +62,7 @@ def build_dataloader(cfg, is_train=True, distributed=True): batch_size=batch_size, shuffle=True if is_train else False, drop_last=True if is_train else False, - use_shared_memory=False, + use_shared_memory=use_shared_memory, num_workers=num_workers) return dataloader -- GitLab