ultralytics 8.2.32 Apple MPS device Autobatch handling (#13568)
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
39fd2661f8
commit
e5477713dd
3 changed files with 4 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||||
|
|
||||||
__version__ = "8.2.31"
|
__version__ = "8.2.32"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -395,7 +395,7 @@ def yaml_print(yaml_file: Union[str, Path, dict]) -> None:
|
||||||
(None)
|
(None)
|
||||||
"""
|
"""
|
||||||
yaml_dict = yaml_load(yaml_file) if isinstance(yaml_file, (str, Path)) else yaml_file
|
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}")
|
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: ")
|
prefix = colorstr("AutoBatch: ")
|
||||||
LOGGER.info(f"{prefix}Computing optimal batch size for imgsz={imgsz} at {fraction * 100}% CUDA memory utilization.")
|
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
|
device = next(model.parameters()).device # get model device
|
||||||
if device.type == "cpu":
|
if device.type in {"cpu", "mps"}:
|
||||||
LOGGER.info(f"{prefix}CUDA not detected, using default CPU batch-size {batch_size}")
|
LOGGER.info(f"{prefix} ⚠️ intended for CUDA devices, using default batch-size {batch_size}")
|
||||||
return batch_size
|
return batch_size
|
||||||
if torch.backends.cudnn.benchmark:
|
if torch.backends.cudnn.benchmark:
|
||||||
LOGGER.info(f"{prefix} ⚠️ Requires torch.backends.cudnn.benchmark=False, using default batch-size {batch_size}")
|
LOGGER.info(f"{prefix} ⚠️ Requires torch.backends.cudnn.benchmark=False, using default batch-size {batch_size}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue