Skip to content

Instantly share code, notes, and snippets.

@yaroslavvb
Created December 27, 2019 23:25
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 yaroslavvb/94c78e1d8a6fc45e70fc94b2ba1d4078 to your computer and use it in GitHub Desktop.
Save yaroslavvb/94c78e1d8a6fc45e70fc94b2ba1d4078 to your computer and use it in GitHub Desktop.
recipe for Determinism in PyTorch
import os, numpy as np, random, torch
np.random.seed(666)
random.seed(666)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
torch.manual_seed(666)
torch.cuda.manual_seed_all(666+int(os.environ.get("RANK", "0")))
torch.set_printoptions(precision=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment