-
Notifications
You must be signed in to change notification settings - Fork 675
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
Make single GPU benchmarking 5x more efficient #2390
Conversation
Signed-off-by: Weilin Xu <[email protected]>
Signed-off-by: Weilin Xu <[email protected]>
Signed-off-by: Weilin Xu <[email protected]>
450479a
to
1003a30
Compare
Is there any reason to set the logging level to DEBUG in benchmarking? The screen output is too verbose in my opinion. anomalib/src/anomalib/utils/logging.py Line 78 in 3a403ae
We also get a little extra speedup if we leave the logging level alone. diff --git a/src/anomalib/utils/logging.py b/src/anomalib/utils/logging.py
index 21f7994f..d73ef440 100644
--- a/src/anomalib/utils/logging.py
+++ b/src/anomalib/utils/logging.py
@@ -74,10 +74,8 @@ def redirect_logs(log_file: str) -> None:
"""
Path(log_file).parent.mkdir(exist_ok=True, parents=True)
logger_file_handler = logging.FileHandler(log_file)
- root_logger = logging.getLogger()
- root_logger.setLevel(logging.DEBUG)
format_string = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
- logging.basicConfig(format=format_string, level=logging.DEBUG, handlers=[logger_file_handler])
+ logging.basicConfig(format=format_string, handlers=[logger_file_handler])
logging.captureWarnings(capture=True)
# remove other handlers from all loggers
loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict] Setting to logging.DEBUG $ time anomalib benchmark --config example_benchmark.yaml
real 1m13.563s
user 4m29.377s
sys 0m25.782s Leave it alone $ time anomalib benchmark --config example_benchmark.yaml
real 1m9.581s
user 4m14.989s
sys 0m24.995s @ashwinvaidya17 @samet-akcay Shell we include the change in this PR for the sake of efficiency? |
@mzweilin, I agree, we log far too many information, which is confusing most of the time. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2390 +/- ##
==========================================
+ Coverage 81.66% 81.68% +0.02%
==========================================
Files 283 283
Lines 12682 12687 +5
==========================================
+ Hits 10357 10364 +7
+ Misses 2325 2323 -2 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Weilin Xu <[email protected]>
📝 Description
This PR makes the benchmarking module 5x more efficient by using
SerialRunner()
instead ofParallelRunner(n_jobs=1)
when there is only one GPU device. The two runners are functionally equivalent, butSerialRunner()
is far more efficient. We need to figure out what makesParallelRunner()
inefficient in the future.Click me to see `example_benchmark.yaml`.
Before
After
1.8x speedup: 2m13s -> 1m13s
with 2.8x less CPU load: 13m40s -> 4m55s
which means the fix makes it 5x more efficient.
✨ Changes
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.