Skip to content

Commit

Permalink
Fix is_torch_xpu_available for torch < 2.3 (#31573)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyeroberts authored Jun 24, 2024
1 parent 2fc9d8e commit 3a49ebe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/transformers/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,13 @@ def is_torch_xpu_available(check_device=False):
if not is_torch_available():
return False

import torch

torch_version = version.parse(_torch_version)
if is_ipex_available():
import intel_extension_for_pytorch # noqa: F401
elif torch_version.major < 2 or (torch_version.major == 2 and torch_version.minor < 4):
return False

import torch

if check_device:
try:
Expand Down

0 comments on commit 3a49ebe

Please sign in to comment.