Установить конкретную версию pytorchPython

Программы на Python
Ответить
Anonymous
 Установить конкретную версию pytorch

Сообщение Anonymous »

Я пытаюсь установить определенную версию torch (вместе с torchvision и torchaudio) для проекта.
Инструкции от в проекте упоминалась команда:

Код: Выделить всё

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
и по соображениям совместимости я установил (после некоторых проб и ошибок) на одну машину с помощью команды:

Код: Выделить всё

pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 -f https://download.pytorch.org/whl/torch_stable.htm
В этой машине все в порядке. Но когда я попытался применить ту же команду, меня ждал сюрприз.

Код: Выделить всё

pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 -f https://download.pytorch.org/whl/torch_stable.htm
Поиск ссылок: https://download.pytorch.org/whl/torch_stable.htm
ОШИБКА: не удалось найти удовлетворяющую версию требование
torch==1.11.0+cu113 (из версий: 1.11.0, 1.12.0, 1.12.1, 1.13.0,
1.13.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 2.5.0, 2.5.1) ОШИБКА: Для torch==1.11.0+cu113 соответствующего дистрибутива не найдено

Таким образом, не существует ни одной версии, в которой конкретно упоминалась бы версия cuda. Просто факельная версия. Итак, когда я выбрал 1.11.0, он был установлен успешно, но с каким cuda не очевидно.
Из pip в cli он вообще не показывался :

Код: Выделить всё

pip list | grep torch
torch 1.11.0

torchaudio 0.11.0

torchvision 0.12.0

но изнутри Python это видно (!):

Код: Выделить всё

>>> import torch
>>> torch.__version__
'1.11.0+cu102'
Итак, я думаю, по какой-то причине по умолчанию была выбрана cuda 10.2. При проверке официальной документации факела предоставляется следующая команда:

Код: Выделить всё

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
и для 11.7 (та, что у меня в этой машине):

Код: Выделить всё

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
Looking in indexes: https://download.pytorch.org/whl/cu117
Requirement already satisfied: torch in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (1.11.0)
Requirement already satisfied: torchvision in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (0.12.0)
Requirement already satisfied: torchaudio in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (0.11.0)
Requirement already satisfied: typing-extensions in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from torch) (4.12.2)
Requirement already satisfied: numpy in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from torchvision) (1.26.4)
Requirement already satisfied: requests in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from torchvision) (2.32.3)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from torchvision) (11.0.0)
Requirement already satisfied: charset-normalizer=2 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from requests->torchvision) (3.4.0)
Requirement already satisfied: idna=2.5 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from requests->torchvision) (3.10)
Requirement already satisfied: urllib3=1.21.1 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from requests->torchvision) (2.2.3)
Requirement already satisfied: certifi>=2017.4.17 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from requests->torchvision) (2024.8.30)
Как можно быть удовлетворенным выбором cuda 10.2?
Даже для конкретной версии факела 1.11.0 результат тот же:

Код: Выделить всё

pip3 install torch==1.11.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
Looking in indexes: https://download.pytorch.org/whl/cu117
Requirement already satisfied: torch==1.11.0 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (1.11.0)
Requirement already satisfied: torchvision in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (0.12.0)
Requirement already satisfied: torchaudio in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (0.11.0)
Requirement already satisfied: typing-extensions in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from torch==1.11.0) (4.12.2)
Requirement already satisfied: numpy in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from torchvision) (1.26.4)
Requirement already satisfied: requests in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from torchvision) (2.32.3)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from torchvision) (11.0.0)
Requirement already satisfied: charset-normalizer=2 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from requests->torchvision) (3.4.0)
Requirement already satisfied: idna=2.5 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from requests->torchvision) (3.10)
Requirement already satisfied: urllib3=1.21.1 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from requests->torchvision) (2.2.3)
Requirement already satisfied: certifi>=2017.4.17 in /home/orfanidis/miniconda3/envs/torch310/lib/python3.10/site-packages (from requests->torchvision) (2024.8.30)
Для справки, на первой машине результат был следующим:

Код: Выделить всё

pip install torch==1.11.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Looking in links: https://download.pytorch.org/whl/torch_stable.html
ERROR: Could not find a version that satisfies the requirement torch==1.11.0+cu111 (from versions:  1.11.0, 1.11.0+cpu, 1.11.0+cu102, 1.11.0+cu113, 1.11.0+cu115, 1.11.0+rocm4.3.1, 1.11.0+rocm4.5.2, 1.12.0, 1.12.0+cpu, 1.12.0+cu102, 1.12.0+cu113, 1.12.0+cu116, 1.12.0+rocm5.0, 1.12.0+rocm5.1.1, 1.12.1, 1.12.1+cpu, 1.12.1+cu102, 1.12.1+cu113, 1.12.1+cu116, 1.12.1+rocm5.0, 1.12.1+rocm5.1.1, 1.13.0, 1.13.0+cpu, 1.13.0+cu116, 1.13.0+cu117, 1.13.0+cu117.with.pypi.cudnn, 1.13.0+rocm5.1.1, 1.13.0+rocm5.2, 1.13.1, 1.13.1+cpu, 1.13.1+cu116, 1.13.1+cu117, 1.13.1+cu117.with.pypi.cudnn, 1.13.1+rocm5.1.1, 1.13.1+rocm5.2, 2.0.0, 2.0.0+cpu, 2.0.0+cpu.cxx11.abi, 2.0.0+cu117, 2.0.0+cu117.with.pypi.cudnn, 2.0.0+cu118, 2.0.0+rocm5.3, 2.0.0+rocm5.4.2, 2.0.1, 2.0.1+cpu, 2.0.1+cpu.cxx11.abi, 2.0.1+cu117, 2.0.1+cu117.with.pypi.cudnn, 2.0.1+cu118, 2.0.1+rocm5.3, 2.0.1+rocm5.4.2, 2.1.0, 2.1.0+cpu, 2.1.0+cpu.cxx11.abi, 2.1.0+cu118, 2.1.0+cu121, 2.1.0+cu121.with.pypi.cudnn, 2.1.0+rocm5.5, 2.1.0+rocm5.6, 2.1.1, 2.1.1+cpu, 2.1.1+cpu.cxx11.abi, 2.1.1+cu118, 2.1.1+cu121, 2.1.1+cu121.with.pypi.cudnn, 2.1.1+rocm5.5, 2.1.1+rocm5.6, 2.1.2, 2.1.2+cpu, 2.1.2+cpu.cxx11.abi, 2.1.2+cu118, 2.1.2+cu121, 2.1.2+cu121.with.pypi.cudnn, 2.1.2+rocm5.5, 2.1.2+rocm5.6, 2.2.0, 2.2.0+cpu, 2.2.0+cpu.cxx11.abi, 2.2.0+cu118, 2.2.0+cu121, 2.2.0+rocm5.6, 2.2.0+rocm5.7, 2.2.1, 2.2.1+cpu, 2.2.1+cpu.cxx11.abi, 2.2.1+cu118, 2.2.1+cu121, 2.2.1+rocm5.6, 2.2.1+rocm5.7, 2.2.2, 2.2.2+cpu, 2.2.2+cpu.cxx11.abi, 2.2.2+cu118, 2.2.2+cu121, 2.2.2+rocm5.6, 2.2.2+rocm5.7, 2.3.0, 2.3.0+cpu, 2.3.0+cpu.cxx11.abi, 2.3.0+cu118, 2.3.0+cu121, 2.3.0+rocm5.7, 2.3.0+rocm6.0, 2.3.1, 2.3.1+cpu, 2.3.1+cpu.cxx11.abi, 2.3.1+cu118, 2.3.1+cu121, 2.3.1+rocm5.7, 2.3.1+rocm6.0, 2.4.0, 2.4.1, 2.5.0, 2.5.1)
ERROR: No matching distribution found for torch==1.11.0+cu111
где в сообщениях об ошибках указана конкретная версия, которую можно выбрать.
Итак, мои вопросы:
а) Почему на некоторых на машинах torch может быть установлена ​​определенная версия cuda, а на других нет.
b) Есть ли разница между официальной командой torch и командой проекта? Я знаю, что -f означает поиск ссылок
c) Более важно, как я могу установить конкретную нужную мне версию, если половина программ игнорирует текущую версию (как сам pip) например)?
Версия Python, которую я использую в своем venv, — 3.10.9 на обеих машинах, но драйверы различаются.

Подробнее здесь: https://stackoverflow.com/questions/791 ... of-pytorch
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»