Add Accelerator API to Imagenet Example#1349
Merged
Merged
Conversation
Signed-off-by: eromomon <edgar.romo.montiel@intel.com>
✅ Deploy Preview for pytorch-examples-preview canceled.
|
dvrogozh
reviewed
Jun 13, 2025
| if use_accel: | ||
| if args.gpu is not None: | ||
| torch.accelerator.set_device_index(args.gpu) | ||
| print("Use GPU: {} for training".format(args.gpu)) |
Contributor
There was a problem hiding this comment.
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?
Contributor
Author
There was a problem hiding this comment.
Solved, print removed
Signed-off-by: Edgar Romo Montiel <edgar.romo.montiel@intel.com>
msaroufim
approved these changes
Jun 16, 2025
soumith
approved these changes
Jun 17, 2025
jataylo
reviewed
Jun 30, 2025
| 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) |
Contributor
There was a problem hiding this comment.
Looks like a typo here argps instead of args
Contributor
There was a problem hiding this comment.
Wanna send me a patch? I'll merge
Contributor
There was a problem hiding this comment.
I was doing something else on nvidia system and had a spare minute. Here is a PR to fix and typo and add respective test:
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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