Skip to content

Instantly share code, notes, and snippets.

@Kitsunetic
Forked from KirillVladimirov/seed_everything.py
Created October 8, 2020 23:53
Show Gist options
  • Save Kitsunetic/b881dbd91d77d17840873743107fe6d2 to your computer and use it in GitHub Desktop.
Save Kitsunetic/b881dbd91d77d17840873743107fe6d2 to your computer and use it in GitHub Desktop.
def seed_everything(seed=1234):
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
seed_everything()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment