Consolidate init_seeds() (#4849)

This commit is contained in:
Glenn Jocher authored and GitHub committed 2021-09-18 13:28:42 +02:00
1 parent 302a1b0bb0
commit 84bfa89236
2 files changed
+5 -13

No files matched your search

-10
View File
@@ -15,7 +15,6 @@ from copy import deepcopy
from pathlib import Path
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
@@ -41,15 +40,6 @@ def torch_distributed_zero_first(local_rank: int):
dist.barrier(device_ids=[0])
def init_torch_seeds(seed=0):
# Speed-reproducibility tradeoff https://pytorch.org/docs/stable/notes/randomness.html
torch.manual_seed(seed)
if seed == 0: # slower, more reproducible
cudnn.benchmark, cudnn.deterministic = False, True
else: # faster, less reproducible
cudnn.benchmark, cudnn.deterministic = True, False
def date_modified(path=__file__):
# return human-readable file modification date, i.e. '2021-3-26'
t = datetime.datetime.fromtimestamp(Path(path).stat().st_mtime)