From 85ea9ceff7d785bf53608edd71804512663a6ab8 Mon Sep 17 00:00:00 2001 From: niuliling123 <51102941+niuliling123@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:37:04 +0800 Subject: [PATCH] fix autotune (#42249) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix autotune in reader.py bug原因:创建dataloader的使用直接使用原始dataloader 等于的方式: new_dataloader = old_dataloader,属于深拷贝,导致后续修改new_dataloader的dataset用于num_workers选择时,会造成old_dataloader的dataset同步被修改。导致模型运行的dataset与实际dataset不相等 --- python/paddle/fluid/reader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/reader.py b/python/paddle/fluid/reader.py index 841c58821d7..3ea3af9ed1c 100644 --- a/python/paddle/fluid/reader.py +++ b/python/paddle/fluid/reader.py @@ -19,6 +19,7 @@ import numpy as np import threading import paddle import time +import copy from .framework import Program, Variable, program_guard, default_main_program, default_startup_program, _non_static_mode, cpu_places, _current_expected_place, _in_eager_without_dygraph_check from .executor import global_scope @@ -214,7 +215,7 @@ class AuToTune(object): return sub_dataset def get_autotune_loader(self): - loader = self.loader + loader = copy.copy(self.loader) batch_size = self.loader.batch_sampler.batch_size if isinstance(self.loader.batch_sampler, paddle.io.DistributedBatchSampler): -- GitLab