Error -> Warn on non-deterministic ops (#3613)

pull/3614/head
Glenn Jocher 1 year ago committed by GitHub
parent e97958ef6f
commit 10eb0b6229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ultralytics/yolo/utils/torch_utils.py

@ -319,9 +319,9 @@ def init_seeds(seed=0, deterministic=False):
torch.cuda.manual_seed(seed) torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed) # for Multi-GPU, exception safe torch.cuda.manual_seed_all(seed) # for Multi-GPU, exception safe
# torch.backends.cudnn.benchmark = True # AutoBatch problem https://github.com/ultralytics/yolov5/issues/9287 # torch.backends.cudnn.benchmark = True # AutoBatch problem https://github.com/ultralytics/yolov5/issues/9287
if deterministic: # https://github.com/ultralytics/yolov5/pull/8213 if deterministic:
if TORCH_2_0: if TORCH_2_0:
torch.use_deterministic_algorithms(True) torch.use_deterministic_algorithms(True, warn_only=True) # warn if deterministic is not possible
torch.backends.cudnn.deterministic = True torch.backends.cudnn.deterministic = True
os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8' os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8'
os.environ['PYTHONHASHSEED'] = str(seed) os.environ['PYTHONHASHSEED'] = str(seed)

Loading…
Cancel
Save