mmengine.utils.track_parallel_progress¶
- mmengine.utils.track_parallel_progress(func, tasks, nproc, initializer=None, initargs=None, bar_width=50, chunksize=1, skip_first=False, keep_order=True, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]¶
Track the progress of parallel task execution with a progress bar.
The built-in
multiprocessing
module is used for process pools and tasks are done withPool.map()
orPool.imap_unordered()
.- Parameters:
func (callable) – The function to be applied to each task.
tasks (Sequence) – If tasks is a tuple, it must contain two elements, the first being the tasks to be completed and the other being the number of tasks. If it is not a tuple, it represents the tasks to be completed.
nproc (int) – Process (worker) number.
initializer (None or callable) – Refer to
multiprocessing.Pool
for details.initargs (None or tuple) – Refer to
multiprocessing.Pool
for details.chunksize (int) – Refer to
multiprocessing.Pool
for details.bar_width (int) – Width of progress bar.
skip_first (bool) – Whether to skip the first sample for each worker when estimating fps, since the initialization step may takes longer.
keep_order (bool) – If True,
Pool.imap()
is used, otherwisePool.imap_unordered()
is used.
- Returns:
The task results.
- Return type: