Unverified 提交 7f7bd6fb authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Set `torch.cuda.manual_seed_all()` for DDP (#8688)

* Set `torch.cuda.manual_seed_all()` for DDP * Update general.py * Update general.py
上级 1c5e92ab
...@@ -203,14 +203,14 @@ def init_seeds(seed=0, deterministic=False): ...@@ -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 if deterministic and check_version(torch.__version__, '1.12.0'): # https://github.com/ultralytics/yolov5/pull/8213
torch.use_deterministic_algorithms(True) torch.use_deterministic_algorithms(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)
random.seed(seed) random.seed(seed)
np.random.seed(seed) np.random.seed(seed)
torch.manual_seed(seed) torch.manual_seed(seed)
cudnn.benchmark, cudnn.deterministic = (False, True) if seed == 0 else (True, False) cudnn.benchmark, cudnn.deterministic = (False, True) if seed == 0 else (True, 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
def intersect_dicts(da, db, exclude=()): def intersect_dicts(da, db, exclude=()):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论