`ultralytics 8.2.32` Apple MPS device Autobatch handling (#13568)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/13780/head v8.2.32
alexwine36 5 months ago committed by GitHub
parent 39fd2661f8
commit e5477713dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ultralytics/__init__.py
  2. 2
      ultralytics/utils/__init__.py
  3. 4
      ultralytics/utils/autobatch.py

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.2.31"
__version__ = "8.2.32"
import os

@ -395,7 +395,7 @@ def yaml_print(yaml_file: Union[str, Path, dict]) -> None:
(None)
"""
yaml_dict = yaml_load(yaml_file) if isinstance(yaml_file, (str, Path)) else yaml_file
dump = yaml.dump(yaml_dict, sort_keys=False, allow_unicode=True)
dump = yaml.dump(yaml_dict, sort_keys=False, allow_unicode=True, width=float("inf"))
LOGGER.info(f"Printing '{colorstr('bold', 'black', yaml_file)}'\n\n{dump}")

@ -45,8 +45,8 @@ def autobatch(model, imgsz=640, fraction=0.60, batch_size=DEFAULT_CFG.batch):
prefix = colorstr("AutoBatch: ")
LOGGER.info(f"{prefix}Computing optimal batch size for imgsz={imgsz} at {fraction * 100}% CUDA memory utilization.")
device = next(model.parameters()).device # get model device
if device.type == "cpu":
LOGGER.info(f"{prefix}CUDA not detected, using default CPU batch-size {batch_size}")
if device.type in {"cpu", "mps"}:
LOGGER.info(f"{prefix} intended for CUDA devices, using default batch-size {batch_size}")
return batch_size
if torch.backends.cudnn.benchmark:
LOGGER.info(f"{prefix} Requires torch.backends.cudnn.benchmark=False, using default batch-size {batch_size}")

Loading…
Cancel
Save