Skip to content

Commit

Permalink
Adding mps as device for Pipeline class (#30080)
Browse files Browse the repository at this point in the history
* adding env variable for mps and is_torch_mps_available for Pipeline

* fix linting errors

* Remove environment overide

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

---------

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
  • Loading branch information
2 people authored and Ita Zaporozhets committed May 14, 2024
1 parent c6d45a3 commit 68ae2f0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/transformers/pipelines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
is_torch_available,
is_torch_cuda_available,
is_torch_mlu_available,
is_torch_mps_available,
is_torch_npu_available,
is_torch_xpu_available,
logging,
Expand Down Expand Up @@ -860,6 +861,8 @@ def __init__(
self.device = torch.device(f"npu:{device}")
elif is_torch_xpu_available(check_device=True):
self.device = torch.device(f"xpu:{device}")
elif is_torch_mps_available():
self.device = torch.device(f"mps:{device}")
else:
raise ValueError(f"{device} unrecognized or not available.")
else:
Expand Down

0 comments on commit 68ae2f0

Please sign in to comment.