picotron/utils.py

7 lines
211 B
Python
Raw Normal View History

2024-09-19 22:06:46 +08:00
import torch, random, numpy as np
def set_all_seed(seed):
for module in [random, np.random]: module.seed(seed)
torch.manual_seed(seed)
if torch.cuda.is_available(): torch.cuda.manual_seed_all(seed)