forked from Lightning-AI/pytorch-lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ddp fix for trainer.test() + add basic ddp tests (Lightning-AI#2997)
* add ddp script variations * add ddp test * rename * shell * test * test * try call * try without subprocess * test * display the error * list all variations * try string * try copy env * debug * pythonpath * path * update test * change * simple ddp test * replace * remove random port * random port * str * clean up * check run spawn * clean up * docs * docs * update test * docs * changelog * changelog
- Loading branch information
Showing
12 changed files
with
122 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Runs either `.fit()` or `.test()` on a single node across multiple gpus. | ||
""" | ||
from argparse import ArgumentParser | ||
|
||
from pytorch_lightning import Trainer, seed_everything | ||
from tests.base import EvalModelTemplate | ||
|
||
|
||
def variation_fit(trainer, model): | ||
trainer.fit(model) | ||
|
||
|
||
def variation_test(trainer, model): | ||
trainer.test(model) | ||
|
||
|
||
def get_variations(): | ||
variations = [ | ||
"variation_fit", | ||
"variation_test", | ||
] | ||
return variations | ||
|
||
|
||
def main(): | ||
seed_everything(1234) | ||
parser = ArgumentParser(add_help=False) | ||
parser = Trainer.add_argparse_args(parser) | ||
parser.add_argument('--variation', default=variation_fit.__name__) | ||
parser.set_defaults(gpus=2) | ||
parser.set_defaults(distributed_backend="ddp") | ||
args = parser.parse_args() | ||
|
||
model = EvalModelTemplate() | ||
trainer = Trainer.from_argparse_args(args) | ||
|
||
# run the chosen variation | ||
run_variation = globals()[args.variation] | ||
run_variation(trainer, model) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters