(seed, cuda_deterministic=False)
| 5 | |
| 6 | |
| 7 | def seed_all(seed, cuda_deterministic=False): |
| 8 | random.seed(seed) |
| 9 | np.random.seed(seed) |
| 10 | torch.manual_seed(seed) |
| 11 | if torch.cuda.is_available(): |
| 12 | torch.cuda.manual_seed(seed) |
| 13 | torch.cuda.manual_seed_all(seed) |
| 14 | if cuda_deterministic: # slower, more reproducible |
| 15 | torch.backends.cudnn.deterministic = True |
| 16 | torch.backends.cudnn.benchmark = False |
| 17 | else: |
| 18 | torch.backends.cudnn.deterministic = False |
| 19 | torch.backends.cudnn.benchmark = True |
searching dependent graphs…