诗歌安装在PIP中的-f旗

发布于 2025-01-29 04:27:42 字数 290 浏览 3 评论 0原文

我需要与诗歌安装包裹(将它们添加到pyproject.toml)。我必须将其翻译成诗歌。但是在文档中,我找不到类似于-f标志的东西。这是命令:

pip install torch == 1.8.1+cu111 torchvision == 0.9.1+cu111 torchaudio == 0.8.1 -f https://download.pytorload.pytorch.org/whl/torch_stable.html < /代码>

有人知道如何翻译吗?

I need to install packages with poetry (add them to pyproject.toml). I have to translate this to poetry. But in the documentation I did not find something similar to the -f flag. This is the command:

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

Does anyone know how to translate that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我为君王 2025-02-05 04:27:42

即使这个问题已经有所老化,但在我的Google搜索中最终也很高。由于我认为我找到了一个非常有用的解决方案,因此我想在这里分享它:

由于诗歌仍然无法解决Pytorch+Cuda捆绑包,因此您必须指定其特定轮子的路径。由于打破了我的用例,在某些平台上需要CUDA支持,并且仅在其他平台上进行CPU,因此我最终得到了此规范:

torch = [
{url="https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp310-cp310-linux_x86_64.whl",markers = "sys_platform == 'linux'"},
{version="^1.11.0",markers = "sys_platform == 'darwin'"}]

torchvision = [
    {url="https://download.pytorch.org/whl/cu113/torchvision-0.12.0%2Bcu113-cp310-cp310-linux_x86_64.whl",markers = "sys_platform == 'linux'"},
    {version="^0.12.0",markers = "sys_platform == 'darwin'"}]

torchaudio = [
    {url="https://download.pytorch.org/whl/cu113/torchaudio-0.11.0%2Bcu113-cp310-cp310-linux_x86_64.whl",markers = "sys_platform == 'linux'"},
    {version="^0.11.0",markers = "sys_platform == 'darwin'"}]

希望这会有所帮助,加油!

Even though this question already aged a bit, it ended up quite high in my google search. Since I think I found a quite useable solution to this problem I wanted to share it here:

Since Poetry still can't resolve pytorch+cuda bundles you have to specify the path to its specific wheel. Since that broke my use case where I need Cuda support on some platforms and CPU only on others, I ended up with this specification:

torch = [
{url="https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp310-cp310-linux_x86_64.whl",markers = "sys_platform == 'linux'"},
{version="^1.11.0",markers = "sys_platform == 'darwin'"}]

torchvision = [
    {url="https://download.pytorch.org/whl/cu113/torchvision-0.12.0%2Bcu113-cp310-cp310-linux_x86_64.whl",markers = "sys_platform == 'linux'"},
    {version="^0.12.0",markers = "sys_platform == 'darwin'"}]

torchaudio = [
    {url="https://download.pytorch.org/whl/cu113/torchaudio-0.11.0%2Bcu113-cp310-cp310-linux_x86_64.whl",markers = "sys_platform == 'linux'"},
    {version="^0.11.0",markers = "sys_platform == 'darwin'"}]

Hope this helps, cheers!

無處可尋 2025-02-05 04:27:42

诗歌(但也是Pip)不知道您是否想要Cuda轮和在哪里找到它,因此您必须明确地告诉它在哪里寻找。

首先,如果要使用CUDA 11.8版本,则应

poetry source add pytorch --priority explicit https://download.pytorch.org/whl/cu118

poetry add --source pytorch torch torchvision

明确

[tool.poetry.dependencies]
python = "^3.9,<3.12"
torch = {version = "^2.0.1", source = "pytorch"}
torchvision = {version = "^0.15.2", source = "pytorch"}

[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"

添加 numpy是依赖性。

这种配置支持Linux和Windows使用CUDA。如果您需要支持MacOS(无CUDA),则可以这样编辑TOML配置:

[tool.poetry.dependencies]
python = "^3.9,<3.12"
torch = [
  {version = "^2.0.1", source = "pytorch", platform = "!=darwin"},
  {version = "^2.0.1", source = "pypi", platform = "darwin"},
]
torchvision = [
  {version = "^0.15.0", source = "pytorch", platform = "!=darwin"},
  {version = "^0.15.0", source = "pypi", platform = "darwin"},
]

[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"

Poetry (but also pip) cannot know if you want the CUDA wheel and where to find it, thus you have to explicitly tell it where to look for.

First, if you want to use the CUDA 11.8 version you should add the source explicitly, like this:

poetry source add pytorch --priority explicit https://download.pytorch.org/whl/cu118

Then, add the PyTorch and Torchvision dependencies mentioning explicitly this source:

poetry add --source pytorch torch torchvision

This should results in a TOML roughtly like this:

[tool.poetry.dependencies]
python = "^3.9,<3.12"
torch = {version = "^2.0.1", source = "pytorch"}
torchvision = {version = "^0.15.2", source = "pytorch"}

[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"

Note that you should also add NumPy as a dependency.

This configuration supports Linux and Windows with CUDA. If you need support for macOS (without CUDA) you can edit the TOML config like this:

[tool.poetry.dependencies]
python = "^3.9,<3.12"
torch = [
  {version = "^2.0.1", source = "pytorch", platform = "!=darwin"},
  {version = "^2.0.1", source = "pypi", platform = "darwin"},
]
torchvision = [
  {version = "^0.15.0", source = "pytorch", platform = "!=darwin"},
  {version = "^0.15.0", source = "pypi", platform = "darwin"},
]

[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu118"
priority = "explicit"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文