-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Add --device
argument to run examples on a specific device
#1288
base: main
Are you sure you want to change the base?
Conversation
- dcgan - gat - gcn - language_translation
✅ Deploy Preview for pytorch-examples-preview canceled.
|
Could someone please review this change? If it makes sense to you, I will proceed. |
This change would be easier to merge if we started testing M1 in CI Do you have any experience in doing this kind of stuff? Basically you can copy this https://github.com/pytorch/examples/blob/main/.github/workflows/main_python.yml change this line to support M1 https://github.com/pytorch/examples/blob/main/.github/workflows/main_python.yml#L16 |
@msaroufim Thanks for your review! The following code snippet is the key of this change. I tested this change on my out-of-tree backend device and the result said OK. if args.cuda:
device = torch.device("cuda")
elif args.mps:
device = torch.device("mps")
else:
- device = torch.device("cpu")
+ device = torch.device(args.device)
ah yes! So should I test this change on MPS and add a workflow in this PR? |
All examples can only be run on CUDA or MPS using
--cuda
or--mps
.This change adds an argument
--device
to make our examples run on a specific device, e.g.,--device cpu
. This will benefit all device manufacturers.cc: @Yikun @FFFrog @hipudding @jgong5 @EikanWang