[Python] ImportError: cannot import name '_get_cpp_backtrace' from 'torch._C', when installing...

Discussão em 'Python' iniciado por Stack, Dezembro 18, 2024.

  1. Stack

    Stack Membro Participativo

    I'm using the docker container on the image named nvcr.io/nvidia/pytorch:22.09-py3.

    In the container, I've made a venv and installed torch.

    Since my NVIDIA driver version is 11.8, I've use pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 as a install command. (I've got from here, https://pytorch.org/)

    But it shows me an error below.

    Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
    [GCC 10.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import torch
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/root/HF/.HF/lib/python3.8/site-packages/torch/__init__.py", line 1119, in <module>
    from ._tensor import Tensor
    File "/root/HF/.HF/lib/python3.8/site-packages/torch/_tensor.py", line 12, in <module>
    import torch.utils.hooks as hooks
    File "/root/HF/.HF/lib/python3.8/site-packages/torch/utils/__init__.py", line 5, in <module>
    from .cpp_backtrace import get_cpp_backtrace
    File "/root/HF/.HF/lib/python3.8/site-packages/torch/utils/cpp_backtrace.py", line 1, in <module>
    from torch._C import _get_cpp_backtrace
    ImportError: cannot import name '_get_cpp_backtrace' from 'torch._C' (/root/HF/.HF/lib/python3.8/site-packages/torch/_C.cpython-38-x86_64-linux-gnu.so)


    Is it because there is some naturally bonded torch version to the container?

    I can find the torch which is originally installed when not using venv. (I don't think it is the reason personally)

    Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
    [GCC 10.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import torch
    >>> print(torch.__version__)
    1.13.0a0+d0d6b1f

    Continue reading...

Compartilhe esta Página