MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / set_random_seed

Function set_random_seed

examples/utils.py:155–171  ·  view source on GitHub ↗
(seed: int)

Source from the content-addressed store, hash-verified

153
154
155def set_random_seed(seed: int):
156 random.seed(seed)
157 np.random.seed(seed)
158 torch.manual_seed(seed)
159 torch.cuda.manual_seed(seed)
160 torch.cuda.manual_seed_all(seed) # For multi-GPU
161 torch.backends.cudnn.deterministic = True
162 torch.backends.cudnn.benchmark = False
163 os.environ['PYTHONHASHSEED'] = str(seed)
164
165 # try:
166 # torch.use_deterministic_algorithms(True)
167 # except Exception as e:
168 # print(f"Could not use deterministic algorithms: {e}")
169
170 torch.backends.cuda.matmul.allow_tf32 = False
171 torch.backends.cudnn.allow_tf32 = False
172
173def verify_random_seed(result_dir: str):
174 """

Callers 6

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected