未验证 提交 5996700b 编写于 作者: L LielinJiang 提交者: GitHub

fix memory leak (#388)

上级 b03e5b8d
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
# limitations under the License. # limitations under the License.
import os import os
import copy
from pathlib import Path from pathlib import Path
from abc import ABCMeta, abstractmethod
from paddle.io import Dataset from paddle.io import Dataset
from abc import ABCMeta, abstractmethod
from .preprocess import build_preprocess from .preprocess import build_preprocess
...@@ -119,7 +119,7 @@ class BaseDataset(Dataset, metaclass=ABCMeta): ...@@ -119,7 +119,7 @@ class BaseDataset(Dataset, metaclass=ABCMeta):
return samples return samples
def __getitem__(self, idx): def __getitem__(self, idx):
datas = self.data_infos[idx] datas = copy.deepcopy(self.data_infos[idx])
if hasattr(self, 'preprocess') and self.preprocess: if hasattr(self, 'preprocess') and self.preprocess:
datas = self.preprocess(datas) datas = self.preprocess(datas)
......
...@@ -62,7 +62,7 @@ def build_dataloader(cfg, is_train=True, distributed=True): ...@@ -62,7 +62,7 @@ def build_dataloader(cfg, is_train=True, distributed=True):
batch_size=batch_size, batch_size=batch_size,
shuffle=True if is_train else False, shuffle=True if is_train else False,
drop_last=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) num_workers=num_workers)
return dataloader return dataloader
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册