tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

Fix torch.accelerator AttributeError in tensorqs_tutorial

Open patrocinio opened this issue 1 month ago • 1 comments

The tutorial was using torch.accelerator.is_available() and torch.accelerator.current_accelerator() which causes an AttributeError in PyTorch versions that don't have the accelerator API.

Changed to use the more widely compatible torch.cuda.is_available() and tensor.to('cuda') pattern that works across all PyTorch versions.

Fixes issue where users get: module 'torch' has no attribute 'accelerator'

Fixes #3629

Description

Checklist

  • [ ] The issue that is being fixed is referred in the description (see above "Fixes #ISSUE_NUMBER")
  • [ ] Only one issue is addressed in this pull request
  • [ ] Labels from the issue that this PR is fixing are added to this pull request
  • [ ] No unnecessary issues are included into this pull request.

patrocinio avatar Nov 26 '25 14:11 patrocinio