".circleci/git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "d1f747fb639235cfcf5e6828038218e72dfb8e0f"
Unverified Commit ae9dd02e authored by André Storhaug's avatar André Storhaug Committed by GitHub
Browse files

Fix incorrect accelerator device handling for MPS in `TrainingArguments` (#31812)

* Fix wrong acclerator device setup when using MPS

* More robust TrainingArguments MPS handling

* Update training_args.py

* Cleanup
parent 4879ac2b
...@@ -48,6 +48,7 @@ from .utils import ( ...@@ -48,6 +48,7 @@ from .utils import (
is_torch_bf16_cpu_available, is_torch_bf16_cpu_available,
is_torch_bf16_gpu_available, is_torch_bf16_gpu_available,
is_torch_mlu_available, is_torch_mlu_available,
is_torch_mps_available,
is_torch_neuroncore_available, is_torch_neuroncore_available,
is_torch_npu_available, is_torch_npu_available,
is_torch_tf32_available, is_torch_tf32_available,
...@@ -2178,6 +2179,8 @@ class TrainingArguments: ...@@ -2178,6 +2179,8 @@ class TrainingArguments:
) )
if self.use_cpu: if self.use_cpu:
device = torch.device("cpu") device = torch.device("cpu")
elif is_torch_mps_available():
device = torch.device("mps")
elif is_torch_xpu_available(): elif is_torch_xpu_available():
if not is_ipex_available() and not is_accelerate_available("0.32.0.dev"): if not is_ipex_available() and not is_accelerate_available("0.32.0.dev"):
raise ImportError("Using the XPU PyTorch backend requires `accelerate>=0.32.0.dev`") raise ImportError("Using the XPU PyTorch backend requires `accelerate>=0.32.0.dev`")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment