-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Progress bars jump around with multiprocessing when using the position kwarg #285
Comments
Hello, what interpreter are you using to run the code? The terminal? IDLE?
|
Directly in the terminal. More specifically, in variations: |
Ah ok so I see the issue is that tqdm is inside the parallelized function. I'm not that much experienced with parallelized Python code, but on We should add this to the README I think? 2016-10-08 22:25 GMT+02:00 Kirill Grigorev notifications@github.com:
|
I only found something pertaining to wrapping pool.map and/or pool.imap_unordered itself, not the loops within parallelized functions (http://stackoverflow.com/questions/32172763/, http://stackoverflow.com/questions/26637273/). And if I'm looking for answers considering joblib, it's even less helpful (http://stackoverflow.com/questions/37804279). Moreover, the tqdm readme states:
So I was kinda thinking this is what it is for... |
That's what I meant, you should put tqdm outside of the pool. But if you really want it to be inside the pool, you also can. You can set The idea would be that the 2016-10-08 23:15 GMT+02:00 Kirill Grigorev notifications@github.com:
|
It's probably the locking issues then... Because as far as the rest goes, that's what I'm doing: mapping the function onto a range of positions. |
Ok then we'll take a look in the next weeks, I'm sure this is fixable
|
Hey @LankyCyril, Can you please try PR #291 to see if it fixes your issue? |
Hi @lrq3000 ! I have commented over there. Sadly nothing seems to have changed for me. |
I'm experiencing the same problem. I believe the issue is about tqdm issuing newlines once each bar is complete. When one process finishes before another, the newline causes the terminal to scroll and the tqdm bars to continue on a new line. The offset bars I think also somehow scroll up, which can cause any subsequent output to be printed on the same lines as remaining bars. I'm not sure what the solution is other than to someone not issue any line scrolls once the progress is complete, and then someone scroll down all at once at the end once everything is complete. I can't seem to force a way around this right now, so any suggestions of a workaround are appreciated. |
About the newline return problem, this might be related to my comment here. The PR won't yet fix everything, but bars should not disappear anymore if you use a lock. |
I had this issue. I decided to use |
I was able to get this somewhat working using from numpy import memmap, uint64
pids = memmap(os.path.join(tempfile.mkdtemp(), 'test'), dtype=uint64, shape=num_cores, mode='w+')
results = Parallel(n_jobs=num_cores)(delayed(utils.do_cut)(......, pids) for task in tasks) In each def do_cut(*args, pids):
if os.getpid() not in pids: pids[np.argmax(test==0)] = os.getpid()
position = np.where(pids==os.getpid())[0][0]
...
for cut in tqdm.tqdm(iterable, desc='{0:s}, {1:d}, {2:d}'.format(did, position, os.getpid()), total=get_n_subtasks(), position=position, leave=False):
... Note that I used Hopefully this solution works for some other people looking for something like this as well. The better way would be to somehow maintain the list of tqdm objects in the parent thread, but I can't find a way to share that correctly (even with callbacks/function serializations) so this is the way I settled on for now. Note: this temporarily seems to fix it in the short-term. After about 10 minutes, things start jumping around again. |
I've noticed similar jumping around - but only in a Win10 command prompt (even with locks). Running the same multiprocessing script in a linux bash terminal worked fine. Maybe see #329. |
When running the above script, I get the following (or similar) output. While it is live, progress bars keep changing places, spamming my entire screen with copies of themselves and empty lines.
Tested with Python 2.7.3 from Ubuntu repos, and with Python 3.5.2 from Continuum Analytics (conda).
Similar problems, naturally, happen when using the joblib module.
P.S. Notice the (venv)$ prompt closer to the top of the output. That's the prompt drawn by the shell after tqdm is "done." When I execute
clear
, of course, it simply scrolls down so that's why you still can see everything.The text was updated successfully, but these errors were encountered: