Skip to content

Commit

Permalink
Set torch.cuda.manual_seed_all() for DDP (ultralytics#8688)
Browse files Browse the repository at this point in the history
* Set `torch.cuda.manual_seed_all()` for DDP

* Update general.py

* Update general.py
  • Loading branch information
glenn-jocher authored and Clay Januhowski committed Sep 8, 2022
1 parent e56330d commit b43d4b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=()):
Expand Down

0 comments on commit b43d4b1

Please sign in to comment.