-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Model summarize displayed twice before training starts #3458
Comments
Tried on master. Working fine. Is it happening with ddp backend only? |
Yes this happens with DDP backend |
on my windows machine, single gpu, happens too. but the logs also appear twice, including all warnings.
¨ |
Just started migration of our codebase to Lightning and the first trainer I write have this issue... Could this be something related with duplicated handlers in logger? It might be that the logger.getLogger() which is a singleton is called twice, so it might be that 2 handlers are initialized, the root handler and another stream handler |
yes, I think that's the case. does my PR not resolve the problem for you? which os are you on? |
I am using Ubuntu 18.04. I tried you PR but unfortunately it does not solve the issue. Maybe I am doing something wrong? I think this is what might be happening: https://jdhao.github.io/2020/06/20/python_duplicate_logging_messages/ |
@JVGD could you try again with my updated branch. sorry, I don't have much experience with this python logging, for me the duplicate messages are resolved locally. I need you as the tester 😄 |
Unfortunately is still showing duplicated logs. I am going to do further testing, but as far as I know I think the pytroch_lightning logger adds an extra StreamHandler to the base root logger. Maybe that is why there are duplicates |
indeed, if we remove the streamhandler, this also solves the problem (for me). can you confirm? |
@JVGD this is all really strange. I checked again with a different machine (also ubuntu 18) and now It's not printing the model summary, while on my notebook it did. |
Mmm really strange @ashwinb, I think we almost got this bug hunted down. I got an hypothesis: maybe you don't see any logs because the root logger does not have any handlers. This means, pytorch_lightning did not add any handlers (because we removed it), and app you are running does not add any other handlers. I think it works in my case because my app already adds a StreamHandler at the beginning. So there is at least one StreamHandler. If it helps, in my python project I check explicitly that there is only one StreamHandler in the root base logger. Maybe doing something like this could help. The idea is to add a StreamHandler only if there is none, but if it is at least one, then use that one (instead of adding another that will print duplicated logs). # Checking if there is already a stream
# handler for avoinding log repetition
console_hanlder_configured = any(
[isinstance(handler, logging.StreamHandler)
for handler in root_logger.handlers])
# If console handler not configured, then add it
if not console_hanlder_configured:
# Handler for logging to stdout
console_handler = logging.StreamHandler()
console_handler.setFormatter(formatter)
console_handler.setLevel(level)
# Adding handler to logger
root_logger.addHandler(console_handler) |
are we good on this? i also made a bunch of stability fixes to ddp including duplicate logging and so on |
Last time I checked it wasn't but I am happy to check it out. The branch to test is still bugfix/duplicated-logging right? |
I still have the duplicate log issue like this:
I'm using pytorch-lightning version 1.1.1, and I configured the root log using I think these lines in
This is the only library having this issue in my hundreds of dependencies. |
Just observed this doubled logging in the recent version of Lightning. It happens in summarize method of the ModelSummary class. |
🐛 Bug
Model summarize is called in two spots, which results in duplication in the logs:
And I'm unsure how it's called again
The first time is with the logger.info(...) since it's formatted. The second time it appears to be logged with
print(...)
since the table formatting doesn't handle newlinesTo Reproduce
Run any training with
weights_summary
set on the trainerExpected behavior
We only call summarize once
The text was updated successfully, but these errors were encountered: