[Python] import torch throws TypeError: can't set attributes of built-in/extension type...

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I installed torch==1.13.0+cu116 and ran Python on the terminal. Then, I did import torch, but I got the following error:

    >>> import torch
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/home/work/temp/venv/lib/python3.8/site-packages/torch/__init__.py", line 231, in <module>
    obj.__module__ = 'torch'
    TypeError: can't set attributes of built-in/extension type 'torch._C.DisableTorchFunctionSubclass'


    I'm using Python 3.8.10, nvcc release 11.6, and driver version 535.104.05

    But the following command not show an error message

    pip install torch==2.3.1 --index-url https://download.pytorch.org/whl/cu121`


    Why is this error occurring?

    Continue reading...

Compartilhe esta Página