From 5b08db884443fe9446138dd835cb98b0b4ba5c54 Mon Sep 17 00:00:00 2001 From: Yao Matrix Date: Thu, 27 Mar 2025 02:45:56 +0800 Subject: [PATCH] fix transformers_cli import relative path issue (#36989) * fix transformers_cli relative import path issue Signed-off-by: Yao, Matrix * fix style Signed-off-by: Yao, Matrix --------- Signed-off-by: Yao, Matrix Co-authored-by: Joao Gante --- src/transformers/commands/env.py | 4 ++++ src/transformers/commands/transformers_cli.py | 17 ++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/transformers/commands/env.py b/src/transformers/commands/env.py index 4162f21e95..4721f1ccf6 100644 --- a/src/transformers/commands/env.py +++ b/src/transformers/commands/env.py @@ -94,6 +94,7 @@ class EnvironmentCommand(BaseTransformersCLICommand): pt_version = torch.__version__ pt_cuda_available = torch.cuda.is_available() + pt_xpu_available = torch.xpu.is_available() pt_npu_available = is_torch_npu_available() pt_hpu_available = is_torch_hpu_available() @@ -151,6 +152,9 @@ class EnvironmentCommand(BaseTransformersCLICommand): if pt_cuda_available: info["Using GPU in script?"] = "" info["GPU type"] = torch.cuda.get_device_name() + elif pt_xpu_available: + info["Using XPU in script?"] = "" + info["XPU type"] = torch.xpu.get_device_name() elif pt_hpu_available: info["Using HPU in script?"] = "" info["HPU type"] = torch.hpu.get_device_name() diff --git a/src/transformers/commands/transformers_cli.py b/src/transformers/commands/transformers_cli.py index 15291dcf89..a066a165d9 100644 --- a/src/transformers/commands/transformers_cli.py +++ b/src/transformers/commands/transformers_cli.py @@ -14,15 +14,14 @@ # limitations under the License. from transformers import HfArgumentParser - -from .add_fast_image_processor import AddFastImageProcessorCommand -from .add_new_model_like import AddNewModelLikeCommand -from .chat import ChatCommand -from .convert import ConvertCommand -from .download import DownloadCommand -from .env import EnvironmentCommand -from .run import RunCommand -from .serving import ServeCommand +from transformers.commands.add_fast_image_processor import AddFastImageProcessorCommand +from transformers.commands.add_new_model_like import AddNewModelLikeCommand +from transformers.commands.chat import ChatCommand +from transformers.commands.convert import ConvertCommand +from transformers.commands.download import DownloadCommand +from transformers.commands.env import EnvironmentCommand +from transformers.commands.run import RunCommand +from transformers.commands.serving import ServeCommand def main():