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

pdb - based debugging with RichProgressBar doesn't show input #10607

Closed
keyraphi opened this issue Nov 18, 2021 · 2 comments · Fixed by #10497
Closed

pdb - based debugging with RichProgressBar doesn't show input #10607

keyraphi opened this issue Nov 18, 2021 · 2 comments · Fixed by #10497
Labels
bug Something isn't working

Comments

@keyraphi
Copy link

🐛 Bug

RichProgressBar swallows the input for pdb or pdbr which makes debugging with those tools virtually impossible.
This is a known issue in rich which does not yet have a solution: See here
With RichProgressBar on the way of replacing tqdm as default it would be good to either document a workaround, or to reconsider that decision.

To Reproduce

Use RichProgressBar in the Trainer callback and put

import pdb; pdb.set_trace()

or

breakpoint()

somewhere inside the training_step(...) or validation_step(...) of your module.

If the execution stops at that breakpoint you will still get the (Pdb) repl, which also works. However the input will not be shown which makes you blind when typing pdb commands.

For example with the RichProgressBar:

...
(Pdb) 
Validation Sanity Check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/2 0:00:08-:--:-- 0.00it/s
'Hello World!' 
(Pdb)

Note that the input `p "Hello World!" is not shown. It should appear in the repl behind (Pdb)
The same Example with ProgressBar

...
(Pdb) p "Hello World!"
'Hello World!'
(Pdb)

Expected behavior

The input to pdb is shown when typed.

Environment

  • PyTorch Lightning Version (e.g., 1.3.0): 1.5.1
  • PyTorch Version (e.g., 1.8): 1.10.0+cu113
  • Python version: 2.8.10
  • OS (e.g., Linux): Linux
  • CUDA/cuDNN version: 11.3 / 8.2
  • GPU models and configuration: Not relevant
  • How you installed PyTorch (conda, pip, source): pip
  • If compiling from source, the output of torch.__config__.show():
  • Any other relevant information:

Additional context

This is not a bug that can/should be fixed in pytorch-lighting. However now that the progress-bar is in PytorchLightning we need this to be pointed out in the documentation.

@keyraphi keyraphi added the bug Something isn't working label Nov 18, 2021
@keyraphi keyraphi changed the title pdb - based debugging with RichProgressBar is not possible pdb - based debugging with RichProgressBar doesn't show input Nov 18, 2021
@kaushikb11
Copy link
Contributor

@keyraphi Could you test this PR out? #10497

We do manual refresh in it, which should make pdb debugging work.

@keyraphi
Copy link
Author

Hey I just manged to find the time to test this.
I realized that by now the PR was merged to main and the branch was deleted.
The change in fact improved the situation. With the above example we now get:

 (Pdb) 
Epoch 0    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/1000000 0:00:00-:--:-- 0.00it/s  p "Hello World!"
'Hello World!'
(Pdb) 

The progress-bar is still rendered after pdb stopped the main-thread, so the typed input appears behind the bar.
This is much better than before, so thank you!

The prints behind the rich progress bar also can be observed when using rich.Console to print/log something inside the training loop. E.g. with console.print():

Epoch 0    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/1000000 0:00:00-:--:-- 0.00it/s  Printed via console.print() in training_step()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants