-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Add Accelerator API to Imagenet Example #1349
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
Conversation
Signed-off-by: eromomon <[email protected]>
✅ Deploy Preview for pytorch-examples-preview canceled.
|
imagenet/main.py
Outdated
if use_accel: | ||
if args.gpu is not None: | ||
torch.accelerator.set_device_index(args.gpu) | ||
print("Use GPU: {} for training".format(args.gpu)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This print seems off as you don't add it in other cases for example in validate
. Is this a leftover debug print? Isn't the print on line 116 not enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved, print removed
Signed-off-by: Edgar Romo Montiel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
target = target.cuda(args.gpu, non_blocking=True) | ||
if use_accel: | ||
if args.gpu is not None and device.type=='cuda': | ||
torch.accelerator.set_device_index(argps.gpu) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a typo here argps instead of args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanna send me a patch? I'll merge
Refactor Imagenet example to utilize torch.accelerator API. torch.accelerator API allows to abstract some of the accelerator specifics in the user scripts. By leveraging this API, the code becomes more adaptable to various hardware accelerators.
CC: @msaroufim, @malfet, @dvrogozh