Skip to content

Add --device argument to run examples on a specific device #1288

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
add --device for mnist_rnn
  • Loading branch information
shink committed Sep 23, 2024
commit 6d552c321c3f3ec7630d3df150159cb7e5021979
4 changes: 3 additions & 1 deletion mnist_rnn/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def main():
help='enables CUDA training')
parser.add_argument('--mps', action="store_true", default=False,
help="enables MPS training")
parser.add_argument('--device', type=str, default='cpu',
help='backend device')
parser.add_argument('--dry-run', action='store_true', default=False,
help='quickly check a single pass')
parser.add_argument('--seed', type=int, default=1, metavar='S',
Expand All @@ -110,7 +112,7 @@ def main():
elif args.mps and not args.cuda:
device = "mps"
else:
device = "cpu"
device = args.device

device = torch.device(device)

Expand Down