Skip to content

Commit

Permalink
Fixed possible race condition while downloading datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
guyleaf committed Oct 14, 2023
1 parent f7bc994 commit 3bb8932
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ def main(args):

cudnn.benchmark = True

data_loader, class_mask = build_continual_dataloader(args)
if args.distributed:
if utils.is_main_process():
# prepare datasets on main process first to avoid race condition while downloading
data_loader, class_mask = build_continual_dataloader(args)

# wait until the main process complete
torch.distributed.barrier()

# let other processes prepare datasets
if not utils.is_main_process():
data_loader, class_mask = build_continual_dataloader(args)
else:
data_loader, class_mask = build_continual_dataloader(args)

print(f"Creating original model: {args.model}")
original_model = create_model(
Expand Down

0 comments on commit 3bb8932

Please sign in to comment.