Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Fixed

- Make single GPU benchmarking 5x more efficient by [mzweilin](https://github.com/mzweilin) in https://github.com/openvinotoolkit/anomalib/pull/2390

### New Contributors

**Full Changelog**:
Expand Down
11 changes: 6 additions & 5 deletions src/anomalib/pipelines/benchmark/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ def _setup_runners(args: dict) -> list[Runner]:
accelerators = args["accelerator"] if isinstance(args["accelerator"], list) else [args["accelerator"]]
runners: list[Runner] = []
for accelerator in accelerators:
if accelerator == "cpu":
runners.append(SerialRunner(BenchmarkJobGenerator("cpu")))
elif accelerator == "cuda":
runners.append(ParallelRunner(BenchmarkJobGenerator("cuda"), n_jobs=torch.cuda.device_count()))
else:
if accelerator not in {"cpu", "cuda"}:
msg = f"Unsupported accelerator: {accelerator}"
raise ValueError(msg)
device_count = torch.cuda.device_count()
if device_count <= 1:
runners.append(SerialRunner(BenchmarkJobGenerator(accelerator)))
else:
runners.append(ParallelRunner(BenchmarkJobGenerator(accelerator), n_jobs=device_count))
return runners
4 changes: 1 addition & 3 deletions src/anomalib/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down