ultralytics 8.2.61 fix num_threads for CPU training (#14544)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
8094df3c47
commit
47ff2b4a76
5 changed files with 239 additions and 110 deletions
|
|
@ -21,6 +21,7 @@ from ultralytics.utils import (
|
|||
DEFAULT_CFG_DICT,
|
||||
DEFAULT_CFG_KEYS,
|
||||
LOGGER,
|
||||
NUM_THREADS,
|
||||
PYTHON_VERSION,
|
||||
TORCHVISION_VERSION,
|
||||
__version__,
|
||||
|
|
@ -172,6 +173,8 @@ def select_device(device="", batch=0, newline=False, verbose=True):
|
|||
s += f"CPU ({get_cpu_info()})\n"
|
||||
arg = "cpu"
|
||||
|
||||
if arg in {"cpu", "mps"}:
|
||||
torch.set_num_threads(NUM_THREADS) # reset OMP_NUM_THREADS for cpu training
|
||||
if verbose:
|
||||
LOGGER.info(s if newline else s.rstrip())
|
||||
return torch.device(arg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue