diff --git a/train.py b/train.py index fd288b0..d89e011 100644 --- a/train.py +++ b/train.py @@ -63,7 +63,7 @@ def train(hyp): weights = opt.weights # initial training weights # Configure - init_seeds() + init_seeds(1) with open(opt.data) as f: data_dict = yaml.load(f, Loader=yaml.FullLoader) # model dict train_path = data_dict['train'] diff --git a/utils/torch_utils.py b/utils/torch_utils.py index d4cd1e8..374b308 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -12,8 +12,11 @@ import torch.nn.functional as F def init_seeds(seed=0): torch.manual_seed(seed) - # Reduce randomness (may be slower on Tesla GPUs) # https://pytorch.org/docs/stable/notes/randomness.html - if seed == 0: + # Speed-reproducibility tradeoff https://pytorch.org/docs/stable/notes/randomness.html + if seed == 0: # slower, more reproducible + cudnn.deterministic = True + cudnn.benchmark = False + else: # faster, less reproducible cudnn.deterministic = False cudnn.benchmark = True