Задать вопрос
Tokishu
@Tokishu
Что?

Как исправить ошибку с установкой и запуском Torch?

Итак, я переустановил винду, и мне понадобилось запустить модель у себя на пк, поставил Torch
PS D:\Reine> pip uninstall torch torchvision torchaudio
Found existing installation: torch 2.4.0+cu118
Uninstalling torch-2.4.0+cu118:
  Would remove:
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\scripts\convert-caffe2-to-onnx.exe
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\scripts\convert-onnx-to-caffe2.exe
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\scripts\torchrun.exe
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\functorch\*
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\torch-2.4.0+cu118.dist-info\*
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\torch\*
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\torchgen\*
Proceed (Y/n)? y
  Successfully uninstalled torch-2.4.0+cu118
Found existing installation: torchvision 0.19.0+cu118
Uninstalling torchvision-0.19.0+cu118:
  Would remove:
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\torchvision-0.19.0+cu118.dist-info\*
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\torchvision\*
Proceed (Y/n)? y
  Successfully uninstalled torchvision-0.19.0+cu118
Found existing installation: torchaudio 2.4.0+cu118
Uninstalling torchaudio-2.4.0+cu118:
  Would remove:
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\torchaudio-2.4.0+cu118.dist-info\*
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\torchaudio\*
    c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages\torio\*
Proceed (Y/n)? y
  Successfully uninstalled torchaudio-2.4.0+cu118
PS D:\Reine> pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://download.pytorch.org/whl/cu118
Collecting torch
  Using cached https://download.pytorch.org/whl/cu118/torch-2.4.0%2Bcu118-cp312-cp312-win_amd64.whl (2692.5 MB)
Collecting torchvision
  Using cached https://download.pytorch.org/whl/cu118/torchvision-0.19.0%2Bcu118-cp312-cp312-win_amd64.whl (5.0 MB)
Collecting torchaudio
  Using cached https://download.pytorch.org/whl/cu118/torchaudio-2.4.0%2Bcu118-cp312-cp312-win_amd64.whl (4.0 MB)
Requirement already satisfied: filelock in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torch) (3.13.1)
Requirement already satisfied: typing-extensions>=4.8.0 in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torch) (4.9.0)
Requirement already satisfied: sympy in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torch) (1.12)
Requirement already satisfied: networkx in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torch) (3.2.1)
Requirement already satisfied: jinja2 in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torch) (3.1.3)
Requirement already satisfied: fsspec in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torch) (2024.2.0)
Requirement already satisfied: setuptools in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torch) (70.0.0)
Requirement already satisfied: numpy in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torchvision) (1.26.3)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from torchvision) (10.2.0)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from jinja2->torch) (2.1.5)
Requirement already satisfied: mpmath>=0.19 in c:\users\tok1s\appdata\local\packages\pythonsoftwarefoundation.python.3.12_qbz5n2kfra8p0\localcache\local-packages\python312\site-packages (from sympy->torch) (1.3.0)
Installing collected packages: torch, torchvision, torchaudio
  WARNING: The scripts convert-caffe2-to-onnx.exe, convert-onnx-to-caffe2.exe and torchrun.exe are installed in 'C:\Users\tok1s\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed torch-2.4.0+cu118 torchaudio-2.4.0+cu118 torchvision-0.19.0+cu118


Если что тут переустанавливаю его, уже какой раз.
Но в итоге когда запускаю скрипт для проверки torch
import torch
print(torch.__version__)

И появляется ошибка
Traceback (most recent call last):
  File "D:\Reine\reine.py", line 1, in <module>
    import torch
  File "C:\Users\tok1s\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\torch\__init__.py", line 148, in <module>
    raise err
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\tok1s\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

При установке зависящих от него библиотек установщик не видит библиотеку вовсе, обратился к GPT, он сказал попробовать переустановить от имени админа, проверить наличие fbgemm.dll, обновить драйверы на видеокарту и переустановить Visual C++ Redistributable.
Ничего не помогло, как это пификсить?
  • Вопрос задан
  • 327 просмотров
Подписаться 2 Средний 4 комментария
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы