Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Fix distributed training test (#420)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #420

The distributed training test was running the local trainer on each process. The `distributed_backend` argument needed to be added since `classy_train.py` now runs the `LocalTrainer` by default.

Reviewed By: vreis

Differential Revision: D20296492

fbshipit-source-id: dbaee937f39d31e7c98db2836b98d7f97307783b
  • Loading branch information
mannatsingh authored and facebook-github-bot committed Mar 6, 2020
1 parent d10fb97 commit ce31b99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions classy_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from pathlib import Path

import torch
from classy_vision.generic.distributed_util import get_rank, get_world_size
from classy_vision.generic.opts import check_generic_args, parse_train_arguments
from classy_vision.generic.registry_utils import import_all_packages_from_directory
from classy_vision.generic.util import load_checkpoint, load_json
Expand Down Expand Up @@ -104,6 +105,10 @@ def main(args, config):

trainer = trainer_class(use_gpu=use_gpu, num_dataloader_workers=args.num_workers)

logging.info(
f"Starting training on rank {get_rank()} worker. "
f"World size is {get_world_size()}"
)
# That's it! When this call returns, training is done.
trainer.train(task)

Expand Down
3 changes: 2 additions & 1 deletion test/trainer_distributed_trainer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def test_training(self):
--device={device} \
--config={self.config_files[config_key]} \
--num_workers=4 \
--log_freq=100
--log_freq=100 \
--distributed_backend=ddp
"""
result = subprocess.run(cmd, shell=True)
success = result.returncode == 0
Expand Down

0 comments on commit ce31b99

Please sign in to comment.