[Python] AttributeError : 'torch' has no 'get_default_device'

Discussão em 'Python' iniciado por Stack, Junho 1, 2025.

  1. Stack

    Stack Membro Participativo

    I’m working on a Python project using these libraries:

    PyTorch 2.2.2 Transformers 4.52.3 Sentence-Transformers 4.1.0 When I run my code, I get this error:

    AttributeError: module 'torch' has no attribute 'get_default_device' It seems the get_default_device method is missing in my installed PyTorch version. Has anyone faced this issue? What versions of PyTorch, Transformers, and Sentence-Transformers are compatible with each other to avoid this error? How can I fix this in my current environment?

    I suspect it’s a compatibility issue between PyTorch and the Transformers or Sentence-Transformers library versions I’m using.

    Continue reading...

Compartilhe esta Página