Skip to content

Incorrect API call #38457

Open
Open
@shashank-shivam

Description

@shashank-shivam

System Info

torch.get_default_device() is not an official PyTorch API (even in 2.2), but it’s being called inside modeling_utils.py in version 4.52.1.

get_torch_context_manager_or_global_device() function is calling the following API
Error - Exception : module 'torch' has no attribute 'get_default_device'

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

HuggingFaceEmbeddings(model_name=self._model_name)

Initialization fails with Exception : module 'torch' has no attribute 'get_default_device'

Expected behavior

Can be replaced with
default_device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions