Skip to content
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

Fix random seed bug of DDP in the ImageNet example #825

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions imagenet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ def main():
args = parser.parse_args()

if args.seed is not None:
random.seed(args.seed)
torch.manual_seed(args.seed)
cudnn.deterministic = True
warnings.warn('You have chosen to seed training. '
'This will turn on the CUDNN deterministic setting, '
'which can slow down your training considerably! '
Expand Down Expand Up @@ -115,6 +112,11 @@ def main():
def main_worker(gpu, ngpus_per_node, args):
global best_acc1
args.gpu = gpu

if args.seed is not None:
random.seed(args.seed)
torch.manual_seed(args.seed)
cudnn.deterministic = True

if args.gpu is not None:
print("Use GPU: {} for training".format(args.gpu))
Expand Down