Modify _log_input_summary function#7811
Open
hyacinth97223 wants to merge 20 commits intoProject-MONAI:devfrom
Open
Modify _log_input_summary function#7811hyacinth97223 wants to merge 20 commits intoProject-MONAI:devfrom
hyacinth97223 wants to merge 20 commits intoProject-MONAI:devfrom
Conversation
Fixes Project-MONAI#7513 Signed-off-by: Ted.Lai <hyacinth97122@gmail.com>
Signed-off-by: Ted.Lai <hyacinth97122@gmail.com>
ccddedf to
7f2633e
Compare
for more information, see https://pre-commit.ci
KumoLiu
reviewed
May 28, 2024
monai/bundle/scripts.py
Outdated
| log_buffer.write(f"> {name}: {pprint_edges(val, PPRINT_CONFIG_N)}\n") | ||
| log_buffer.write("---\n\n") | ||
|
|
||
| logger.info(log_buffer.getvalue()) |
Contributor
There was a problem hiding this comment.
This change may still not solve the issue mentioned in #7513?
Member
There was a problem hiding this comment.
What it seems to me will happen here is the message will be written all at once with one call to logger.info() which has a greater chance of appearing all at once in the output in the presence of multiple GPUs. This is only by chance and isn't guaranteed. What we need in the case of multiple GPUs is to identify which process is rank 0 and only it writes to the logger by default but with an option to allow everyone to write if desired. With the torch.distributed package this would be:
import torch.distributed as dist
...
rank = dist.get_rank() if dist.is_initialized() else 0Signed-off-by: Ted.Lai <hyacinth97122@gmail.com>
… into fix-issue-7513
I modify the _log_input_summary function and add the following
functionality:
Logs the input summary of a MONAI bundle script to the console and a local log file.
Each rank's logs are tagged with their rank number and saved to individual log files.
Reads the base log path from the logging.conf file and creates a separate log file for each rank.
Add log_all_ranks as a parameter to determine whether to log all ranks or only rank 0.
for more information, see https://pre-commit.ci
Signed-off-by: Ted.Lai <hyacinth97122@gmail.com>
Signed-off-by: Ted.Lai <hyacinth97122@gmail.com>
Signed-off-by: Ted.Lai <hyacinth97122@gmail.com>
for more information, see https://pre-commit.ci
Signed-off-by: Ted.Lai <hyacinth97122@gmail.com>
… into fix-issue-7513 Logs the input summary of a MONAI bundle script to the console and a local log file. Each rank's logs are tagged with their rank number and saved to individual log files. Reads the base log path from the logging.conf file and creates a separate log file for each rank. !Add log_all_ranks as a parameter to determine whether to log all ranks or only rank 0.
Signed-off-by: Ted.Lai <hyacinth97122@gmail.com>
… into fix-issue-7513 Logs the input summary of a MONAI bundle script to the console and a local log file. Each rank's logs are tagged with their rank number and saved to individual log files. Reads the base log path from the logging.conf file and creates a separate log file for each rank. Add log_all_ranks as a parameter to determine whether to log all ranks or only rank 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7513
Description
The _log_input_summary() function has been modified. The original output method using logger.info() has been changed to log_buffer.write().
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.