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

example: pytorch_lightning_mnist.py #3290

Merged
merged 1 commit into from Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/pytorch/pytorch_lightning_mnist.py
Expand Up @@ -110,8 +110,12 @@ def test():

if __name__ == '__main__':
args = parser.parse_args()
args.cuda = not args.no_cuda and torch.cuda.is_available()
torch.manual_seed(args.seed)
hvd.init()
args.cuda = not args.no_cuda and torch.cuda.is_available()
if args.cuda:
torch.cuda.set_device(hvd.local_rank())
torch.cuda.manual_seed(args.seed)

kwargs = {'num_workers': 2}
# When supported, use 'forkserver' to spawn dataloader workers instead of 'fork' to prevent
Expand Down Expand Up @@ -205,4 +209,3 @@ def on_train_end(self, trainer, model):
if args.cuda:
model = model.cuda()
test()