Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eromomon
Copy link
Contributor

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

Copy link

netlify bot commented May 19, 2025

Deploy Preview for pytorch-examples-preview canceled.

Name Link
🔨 Latest commit cd2b7f2
🔍 Latest deploy log https://app.netlify.com/projects/pytorch-examples-preview/deploys/684cc8192d044d000845933f

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))
Copy link
Contributor

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?

Copy link
Contributor Author

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]>
@eromomon eromomon requested a review from dvrogozh June 14, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants