Skip to content
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

Issues with tqdm and multiple bars when running under tmux #1315

Open
5 of 6 tasks
ronped opened this issue Apr 10, 2022 · 5 comments
Open
5 of 6 tasks

Issues with tqdm and multiple bars when running under tmux #1315

ronped opened this issue Apr 10, 2022 · 5 comments
Labels
invalid ⛔ Not-an-issue or upstream (not-our-issue) need-feedback 📢 We need your response (question) p2-bug-warning ⚠ Visual output bad

Comments

@ronped
Copy link

ronped commented Apr 10, 2022

  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable:
import tqdm
import time
import sys

print(tqdm.__version__, sys.version, sys.platform)
array = range(1000)
t = [None]*2

for pos in range(len(t)):
    t[pos] = tqdm.tqdm(total=len(array),
                   desc="Progress bar {}".format(pos),
                   position=pos,
                   dynamic_ncols=True)

for value in array:
    for pos in range(len(t)):
        t[pos].update()
        time.sleep(0.1)

Gives me output like this:

4.59.0 3.8.5 (default, Sep  4 2020, 07:30:14) 
[GCC 7.3.0] linux
Progress bar 0:   0%|                                                                                                                                                                                                                                  | 0/1000 [00:00<?, ?it/s]
Progress bar 0:   0%|▍                                                                                                                                                                                                                         | 2/1000 [00:00<01:40,  9.95it/s
Progress bar 0:   0%|▋                                                                                                                                                                                                                         | 3/1000 [00:00<02:21,  7.02it/s
Progress bar 0:   0%|▊                                                                                                                                                                                                                         | 4/1000 [00:00<02:43,  6.09it/s
Progress bar 0:   0%|▋                                                                                                                                                                                                                         | 3/1000 [00:00<02:21,  7.02it/s]
Progress bar 1:   0%|▍                                                                                                                                                                                                                         | 2/1000 [00:00<02:39,  6.27it/s]
Progress bar 0:   0%|█                                                                                                                                                                                                                         | 5/1000 [00:00<02:56,  5.65it/s]
Progress bar 0:   1%|█▎                                                                                                                                                                                                                        | 6/1000 [00:01<03:03,  5.40it/s]
Progress bar 0:   1%|█▌                                                                                                                                                                                                                        | 7/1000 [00:01<03:08,  5.26it/s]
Progress bar 0:   1%|█▋                                                                                                                                                                                                                        | 8/1000 [00:01<03:12,  5.17it/s]
Progress bar 0:   1%|█▉                                                                                                                                                                                                                        | 9/1000 [00:01<03:14,  5.10it/s]

When not running under tmux it works fine so I am not sure if this is an issue with tqdm or tmux. This also worked fine when I was running under python 2 before upgrading to python 3. I also notice that now with python 3 and tmux that some remains from tqdm from one screen tends to stay in the terminal even if I switch screen in tmux. Not sure what is different from python 2 to 3 that would cause this? I have also tried to redirect output to a file and I see output that looks sensible both when running under tmux. I have tried several versions of tmux, but the latest one was 3.2.

@ronped
Copy link
Author

ronped commented Apr 10, 2022

I tried recreating this myself on my macbook using the same versions of tmux, python and tqdm and I am not able to reproduce - so it is highly unlikely that it is any issue with tqdm. So I am seeing this when I am using macos Terminal app and mosh to connect to an ssh server on a system running RH linux with the tool versions given above. Any tips on how to debug this?

@casperdcl
Copy link
Sponsor Member

I also use tmux on Ubuntu and have no issues.

If you resize a panel mid-execution, you need dynamic_ncols=True.

@casperdcl casperdcl added invalid ⛔ Not-an-issue or upstream (not-our-issue) need-feedback 📢 We need your response (question) p2-bug-warning ⚠ Visual output bad labels Jun 18, 2022
@adyotag
Copy link

adyotag commented Aug 22, 2023

I can confirm the same issue - using dynamic_ncols as True did not change anything for me unfortunately. I use Kubuntu.

@MichalTrz
Copy link

I can also confirm this issue. It never bothered me enough to look for a solution though. It happens on multiple remote servers where I have some ML training.
It usually happens when I run a loop with tqdm and then press some button on my keyboard (usually by accident) when attached to the tmux terminal.
Another way it also happens is when I tmux attach into the tmux terminal with tqdm loop running. But only if I do that several times in a short time span (during the same loop).
I am running Ubuntu Linux 18 and 20 and multiple versions of Python 3.6+.

Ill try the dynamic_ncols=True and let you know if it helps.

@dslemusp
Copy link

dslemusp commented Mar 1, 2024

I can also confirm this issue. It never bothered me enough to look for a solution though. It happens on multiple remote servers where I have some ML training. It usually happens when I run a loop with tqdm and then press some button on my keyboard (usually by accident) when attached to the tmux terminal. Another way it also happens is when I tmux attach into the tmux terminal with tqdm loop running. But only if I do that several times in a short time span (during the same loop). I am running Ubuntu Linux 18 and 20 and multiple versions of Python 3.6+.

Ill try the dynamic_ncols=True and let you know if it helps.

Same here. Using tmux to attach to an ubuntu session from my MacBook Pro. Same behaviour when I accidentally pressed a key in the session. Multiple progress bars per logging output printed.

Did the dynamic_ncols = True worked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid ⛔ Not-an-issue or upstream (not-our-issue) need-feedback 📢 We need your response (question) p2-bug-warning ⚠ Visual output bad
Projects
None yet
Development

No branches or pull requests

5 participants