Created
May 20, 2025 16:15
-
-
Save SJCaldwell/584dc66a8777ab5dfe644c6f4a5c5a33 to your computer and use it in GitHub Desktop.
Striving for reproducibility in pytorch (many seeds)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import numpy as np | |
def set_seeds(seed=42): | |
random.seed(seed) | |
np.random.seed(seed) | |
torch.manual_seed(seed) | |
torch.cuda.manual_seed(seed) | |
torch.cuda.manual_seed_all(seed) # for multi-GPU | |
torch.backends.cudnn.deterministic = True | |
torch.backends.cudnn.benchmark = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment