python - How can we use tqdm in a parallel execution with joblib? -
i want run function in parallel, , wait until parallel nodes done, using joblib. in example:
from math import sqrt joblib import parallel, delayed parallel(n_jobs=2)(delayed(sqrt)(i ** 2) in range(10))
but, want execution seen in single progressbar tqdm, showing how many jobs has been completed.
how that?
if problem consists of many parts, split parts k
subgroups, run each subgroup in parallel , update progressbar in between, resulting in k
updates of progress.
this demonstrated in following example documentation.
>>> parallel(n_jobs=2) parallel: ... accumulator = 0. ... n_iter = 0 ... while accumulator < 1000: ... results = parallel(delayed(sqrt)(accumulator + ** 2) ... in range(5)) ... accumulator += sum(results) # synchronization barrier ... n_iter += 1
https://pythonhosted.org/joblib/parallel.html#reusing-a-pool-of-workers
Comments
Post a Comment