From b43d4b106054fe22a40126277e5cc18fd73e9eb1 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 23 Jul 2022 18:24:14 +0200 Subject: [PATCH] Set `torch.cuda.manual_seed_all()` for DDP (#8688) * Set `torch.cuda.manual_seed_all()` for DDP * Update general.py * Update general.py --- utils/general.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/general.py b/utils/general.py index 925f7fbf0ecb..b049ce469a71 100755 --- a/utils/general.py +++ b/utils/general.py @@ -203,14 +203,14 @@ def init_seeds(seed=0, deterministic=False): if deterministic and check_version(torch.__version__, '1.12.0'): # https://github.com/ultralytics/yolov5/pull/8213 torch.use_deterministic_algorithms(True) os.environ['CUBLAS_WORKSPACE_CONFIG'] = ':4096:8' - # os.environ['PYTHONHASHSEED'] = str(seed) + os.environ['PYTHONHASHSEED'] = str(seed) random.seed(seed) np.random.seed(seed) torch.manual_seed(seed) cudnn.benchmark, cudnn.deterministic = (False, True) if seed == 0 else (True, False) - # torch.cuda.manual_seed(seed) - # torch.cuda.manual_seed_all(seed) # for multi GPU, exception safe + torch.cuda.manual_seed(seed) + torch.cuda.manual_seed_all(seed) # for Multi-GPU, exception safe def intersect_dicts(da, db, exclude=()):