Skip to content

Instantly share code, notes, and snippets.

@mmuratarat
Created October 8, 2023 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmuratarat/057edb95dd4c59270fec99d2cb776310 to your computer and use it in GitHub Desktop.
Save mmuratarat/057edb95dd4c59270fec99d2cb776310 to your computer and use it in GitHub Desktop.
reproducibility
def seed_everything(seed: int):
import random, os
import numpy as np
import torch
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
torch.backends.cudnn.benchmark = True
seed_everything(seed=42)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment