未验证 提交 e5137cb2 编写于 作者: W wangguanzhong 提交者: GitHub

fix default value of bufsize (#380)

* add devices_num on reader

* refine capacity value

* refine bufsize
上级 58d33493
...@@ -44,7 +44,7 @@ TrainReader: ...@@ -44,7 +44,7 @@ TrainReader:
shuffle: true shuffle: true
drop_last: true drop_last: true
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
use_process: true use_process: true
EvalReader: EvalReader:
...@@ -76,7 +76,7 @@ EvalReader: ...@@ -76,7 +76,7 @@ EvalReader:
batch_size: 8 batch_size: 8
drop_empty: false drop_empty: false
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
TestReader: TestReader:
inputs_def: inputs_def:
......
...@@ -116,7 +116,7 @@ EvalReader: ...@@ -116,7 +116,7 @@ EvalReader:
std: [127.502231, 127.502231, 127.502231] std: [127.502231, 127.502231, 127.502231]
batch_size: 32 batch_size: 32
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
use_process: false use_process: false
TestReader: TestReader:
......
...@@ -93,7 +93,7 @@ TrainReader: ...@@ -93,7 +93,7 @@ TrainReader:
batch_size: 8 batch_size: 8
shuffle: true shuffle: true
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
use_process: true use_process: true
drop_empty: true drop_empty: true
...@@ -123,7 +123,7 @@ EvalReader: ...@@ -123,7 +123,7 @@ EvalReader:
std: [1, 1, 1] std: [1, 1, 1]
batch_size: 16 batch_size: 16
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
TestReader: TestReader:
inputs_def: inputs_def:
......
...@@ -93,7 +93,7 @@ TrainReader: ...@@ -93,7 +93,7 @@ TrainReader:
batch_size: 8 batch_size: 8
shuffle: true shuffle: true
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
use_process: true use_process: true
EvalReader: EvalReader:
...@@ -122,7 +122,7 @@ EvalReader: ...@@ -122,7 +122,7 @@ EvalReader:
std: [1, 1, 1] std: [1, 1, 1]
batch_size: 32 batch_size: 32
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
TestReader: TestReader:
inputs_def: inputs_def:
......
...@@ -96,7 +96,7 @@ TrainReader: ...@@ -96,7 +96,7 @@ TrainReader:
batch_size: 8 batch_size: 8
shuffle: true shuffle: true
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
use_process: true use_process: true
EvalReader: EvalReader:
...@@ -124,7 +124,7 @@ EvalReader: ...@@ -124,7 +124,7 @@ EvalReader:
std: [1, 1, 1] std: [1, 1, 1]
batch_size: 8 batch_size: 8
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
drop_empty: false drop_empty: false
TestReader: TestReader:
......
...@@ -97,7 +97,7 @@ TrainReader: ...@@ -97,7 +97,7 @@ TrainReader:
batch_size: 8 batch_size: 8
shuffle: true shuffle: true
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
use_process: true use_process: true
EvalReader: EvalReader:
...@@ -126,7 +126,7 @@ EvalReader: ...@@ -126,7 +126,7 @@ EvalReader:
std: [1, 1, 1] std: [1, 1, 1]
batch_size: 32 batch_size: 32
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
TestReader: TestReader:
inputs_def: inputs_def:
......
...@@ -51,7 +51,7 @@ TrainReader: ...@@ -51,7 +51,7 @@ TrainReader:
mixup_epoch: 250 mixup_epoch: 250
drop_last: true drop_last: true
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
use_process: true use_process: true
...@@ -84,7 +84,7 @@ EvalReader: ...@@ -84,7 +84,7 @@ EvalReader:
batch_size: 8 batch_size: 8
drop_empty: false drop_empty: false
worker_num: 8 worker_num: 8
bufsize: 32 bufsize: 16
TestReader: TestReader:
inputs_def: inputs_def:
......
...@@ -179,6 +179,7 @@ class Reader(object): ...@@ -179,6 +179,7 @@ class Reader(object):
use_process is true. Default 3G. use_process is true. Default 3G.
inputs_def (dict): network input definition use to get input fields, inputs_def (dict): network input definition use to get input fields,
which is used to determine the order of returned data. which is used to determine the order of returned data.
devices_num (int): number of devices.
""" """
def __init__(self, def __init__(self,
...@@ -195,9 +196,10 @@ class Reader(object): ...@@ -195,9 +196,10 @@ class Reader(object):
use_process=False, use_process=False,
use_fine_grained_loss=False, use_fine_grained_loss=False,
num_classes=80, num_classes=80,
bufsize=100, bufsize=-1,
memsize='3G', memsize='3G',
inputs_def=None): inputs_def=None,
devices_num=1):
self._dataset = dataset self._dataset = dataset
self._roidbs = self._dataset.get_roidb() self._roidbs = self._dataset.get_roidb()
self._fields = copy.deepcopy(inputs_def[ self._fields = copy.deepcopy(inputs_def[
...@@ -256,6 +258,7 @@ class Reader(object): ...@@ -256,6 +258,7 @@ class Reader(object):
self._parallel = None self._parallel = None
if self._worker_num > -1: if self._worker_num > -1:
task = functools.partial(self.worker, self._drop_empty) task = functools.partial(self.worker, self._drop_empty)
bufsize = devices_num * 2 if bufsize == -1 else bufsize
self._parallel = ParallelMap(self, task, worker_num, bufsize, self._parallel = ParallelMap(self, task, worker_num, bufsize,
use_process, memsize) use_process, memsize)
...@@ -388,7 +391,7 @@ class Reader(object): ...@@ -388,7 +391,7 @@ class Reader(object):
self._parallel.stop() self._parallel.stop()
def create_reader(cfg, max_iter=0, global_cfg=None): def create_reader(cfg, max_iter=0, global_cfg=None, devices_num=1):
""" """
Return iterable data reader. Return iterable data reader.
...@@ -403,6 +406,7 @@ def create_reader(cfg, max_iter=0, global_cfg=None): ...@@ -403,6 +406,7 @@ def create_reader(cfg, max_iter=0, global_cfg=None):
cfg['use_fine_grained_loss'] = getattr(global_cfg, cfg['use_fine_grained_loss'] = getattr(global_cfg,
'use_fine_grained_loss', False) 'use_fine_grained_loss', False)
cfg['num_classes'] = getattr(global_cfg, 'num_classes', 80) cfg['num_classes'] = getattr(global_cfg, 'num_classes', 80)
cfg['devices_num'] = devices_num
reader = Reader(**cfg)() reader = Reader(**cfg)()
def _reader(): def _reader():
......
...@@ -198,7 +198,7 @@ class BlazeFace(object): ...@@ -198,7 +198,7 @@ class BlazeFace(object):
lod_level=inputs_def[key]['lod_level'])) for key in fields]) lod_level=inputs_def[key]['lod_level'])) for key in fields])
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -421,7 +421,7 @@ class CascadeMaskRCNN(object): ...@@ -421,7 +421,7 @@ class CascadeMaskRCNN(object):
use_dataloader = use_dataloader and not mask_branch use_dataloader = use_dataloader and not mask_branch
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -318,7 +318,7 @@ class CascadeRCNN(object): ...@@ -318,7 +318,7 @@ class CascadeRCNN(object):
lod_level=inputs_def[key]['lod_level'])) for key in fields]) lod_level=inputs_def[key]['lod_level'])) for key in fields])
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -301,7 +301,7 @@ class CascadeRCNNClsAware(object): ...@@ -301,7 +301,7 @@ class CascadeRCNNClsAware(object):
lod_level=inputs_def[key]['lod_level'])) for key in fields]) lod_level=inputs_def[key]['lod_level'])) for key in fields])
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -172,7 +172,7 @@ class FaceBoxes(object): ...@@ -172,7 +172,7 @@ class FaceBoxes(object):
lod_level=inputs_def[key]['lod_level'])) for key in fields]) lod_level=inputs_def[key]['lod_level'])) for key in fields])
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -231,7 +231,7 @@ class FasterRCNN(object): ...@@ -231,7 +231,7 @@ class FasterRCNN(object):
lod_level=inputs_def[key]['lod_level'])) for key in fields]) lod_level=inputs_def[key]['lod_level'])) for key in fields])
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -324,7 +324,7 @@ class MaskRCNN(object): ...@@ -324,7 +324,7 @@ class MaskRCNN(object):
use_dataloader = use_dataloader and not mask_branch use_dataloader = use_dataloader and not mask_branch
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -114,7 +114,7 @@ class RetinaNet(object): ...@@ -114,7 +114,7 @@ class RetinaNet(object):
lod_level=inputs_def[key]['lod_level'])) for key in fields]) lod_level=inputs_def[key]['lod_level'])) for key in fields])
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -118,7 +118,7 @@ class SSD(object): ...@@ -118,7 +118,7 @@ class SSD(object):
lod_level=inputs_def[key]['lod_level'])) for key in fields]) lod_level=inputs_def[key]['lod_level'])) for key in fields])
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -147,7 +147,7 @@ class YOLOv3(object): ...@@ -147,7 +147,7 @@ class YOLOv3(object):
lod_level=inputs_def[key]['lod_level'])) for key in fields]) lod_level=inputs_def[key]['lod_level'])) for key in fields])
loader = fluid.io.DataLoader.from_generator( loader = fluid.io.DataLoader.from_generator(
feed_list=list(feed_vars.values()), feed_list=list(feed_vars.values()),
capacity=64, capacity=16,
use_double_buffer=True, use_double_buffer=True,
iterable=iterable) if use_dataloader else None iterable=iterable) if use_dataloader else None
return feed_vars, loader return feed_vars, loader
......
...@@ -84,7 +84,7 @@ def main(): ...@@ -84,7 +84,7 @@ def main():
fetches = model.eval(feed_vars, multi_scale_test) fetches = model.eval(feed_vars, multi_scale_test)
eval_prog = eval_prog.clone(True) eval_prog = eval_prog.clone(True)
reader = create_reader(cfg.EvalReader) reader = create_reader(cfg.EvalReader, devices_num=1)
loader.set_sample_list_generator(reader, place) loader.set_sample_list_generator(reader, place)
dataset = cfg['EvalReader']['dataset'] dataset = cfg['EvalReader']['dataset']
......
...@@ -130,7 +130,7 @@ def main(): ...@@ -130,7 +130,7 @@ def main():
test_fetches = model.test(feed_vars) test_fetches = model.test(feed_vars)
infer_prog = infer_prog.clone(True) infer_prog = infer_prog.clone(True)
reader = create_reader(cfg.TestReader) reader = create_reader(cfg.TestReader, devices_num=1)
loader.set_sample_list_generator(reader, place) loader.set_sample_list_generator(reader, place)
exe.run(startup_prog) exe.run(startup_prog)
......
...@@ -144,7 +144,7 @@ def main(): ...@@ -144,7 +144,7 @@ def main():
fetches = model.eval(feed_vars) fetches = model.eval(feed_vars)
eval_prog = eval_prog.clone(True) eval_prog = eval_prog.clone(True)
eval_reader = create_reader(cfg.EvalReader) eval_reader = create_reader(cfg.EvalReader, devices_num=1)
eval_loader.set_sample_list_generator(eval_reader, place) eval_loader.set_sample_list_generator(eval_reader, place)
# parse eval fetches # parse eval fetches
...@@ -200,8 +200,10 @@ def main(): ...@@ -200,8 +200,10 @@ def main():
checkpoint.load_params( checkpoint.load_params(
exe, train_prog, cfg.pretrain_weights, ignore_params=ignore_params) exe, train_prog, cfg.pretrain_weights, ignore_params=ignore_params)
train_reader = create_reader(cfg.TrainReader, (cfg.max_iters - start_iter) * train_reader = create_reader(
devices_num, cfg) cfg.TrainReader, (cfg.max_iters - start_iter) * devices_num,
cfg,
devices_num=devices_num)
train_loader.set_sample_list_generator(train_reader, place) train_loader.set_sample_list_generator(train_reader, place)
# whether output bbox is normalized in model output layer # whether output bbox is normalized in model output layer
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册