Skip to content

add deterministic flag + functionality #853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@
# Misc
parser.add_argument('--seed', type=int, default=42, metavar='S',
help='random seed (default: 42)')
parser.add_argument('--deterministic', action='store_true', default=False,
help="Whether to use deterministic algorithms (may slightly decrease run time performance)")
parser.add_argument('--log-interval', type=int, default=50, metavar='N',
help='how many batches to wait before logging training status')
parser.add_argument('--recovery-interval', type=int, default=0, metavar='N',
Expand Down Expand Up @@ -345,6 +347,8 @@ def main():
"Install NVIDA apex or upgrade to PyTorch 1.6")

random_seed(args.seed, args.rank)
# NOTE we want to make sure deterministic is set after random_seed
torch.backends.cudnn.deterministic = args.deterministic

model = create_model(
args.model,
Expand Down