MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / set_seed

Function set_seed

utils/train.py:88–107  ·  view source on GitHub ↗
(seed)

Source from the content-addressed store, hash-verified

86
87
88def set_seed(seed):
89 # seed init.
90 random.seed(seed)
91 np.random.seed(seed)
92 os.environ["PYTHONHASHSEED"] = str(seed)
93
94 # torch seed init.
95 torch.manual_seed(seed)
96 torch.cuda.manual_seed(seed)
97 torch.cuda.manual_seed_all(seed)
98
99 torch.backends.cudnn.deterministic = True
100 torch.backends.cudnn.benchmark = False
101 torch.backends.cudnn.enabled = True # train speed is slower after enabling this opts.
102
103 # https://pytorch.org/docs/stable/generated/torch.use_deterministic_algorithms.html
104 os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":16:8"
105
106 # avoiding nondeterministic algorithms (see https://pytorch.org/docs/stable/notes/randomness.html)
107 torch.use_deterministic_algorithms(True, warn_only=True)
108
109
110with Engine(custom_parser=parser) as engine:

Callers 1

train.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected