【问题标题】:Cannot install torchvision via poetry in windows无法通过 windows 中的诗歌安装 torchvision
【发布时间】:2022-03-01 23:41:58
【问题描述】:

感谢此处的答案,我成功安装了 pytorch Poetry and PyTorch.

但是,我仍然无法通过诗歌安装 torchvision。

> poetry add torchvision==0.8.2

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing torchvision (0.8.2)

  RuntimeError

  Unable to find installation candidates for torchvision (0.8.2)

  at ~\.poetry\lib\poetry\installation\chooser.py:72 in choose_for
       68│ 
       69│             links.append(link)
       70│
       71│         if not links:
    →  72│             raise RuntimeError(
       73│                 "Unable to find installation candidates for {}".format(package)
       74│             )
       75│
       76│         # Get the best link


Failed to add packages, reverting the pyproject.toml file to its original content.

我用谷歌搜索了一些答案,上面写着“只是pip install torchvision”。 但我怀疑它是否有效,因为根据 PyPi(https://pypi.org/project/torchvision/#files),Windows 没有轮文件。我试了一下,果然失败了。

有什么方法可以在 windows 中安装与最新的 torch(1.7.1) 兼容的最新的 torchvisin 吗? + 通过诗歌?

【问题讨论】:

    标签: python pytorch python-poetry


    【解决方案1】:
    1. https://download.pytorch.org/whl/torch_stable.html 中查找您要安装的版本(torchvision 版本、python 版本、CUDA 版本、操作系统等)
    2. 将 URL 依赖项添加到您的 pyproject.toml 文件中。例如,我的依赖项中有 torchvision 1.8.0 使用以下内容
    [tool.poetry.dependencies]
    python = "^3.8"
    torch = {url = "https://download.pytorch.org/whl/cu102/torch-1.8.0-cp38-cp38-win_amd64.whl"}
    torchvision = {url = "https://download.pytorch.org/whl/cu102/torchvision-0.9.0-cp38-cp38-win_amd64.whl"}
    
    1. 从您激活的虚拟环境中执行poetry update torchvision,您应该一切顺利。

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,我刚刚重新打开终端,一切正常。我想我是在一些错误的环境中。

      【讨论】:

        猜你喜欢
        • 2021-10-23
        • 2020-10-12
        • 1970-01-01
        • 2022-12-31
        • 2022-11-13
        • 2022-08-11
        • 2015-08-02
        • 1970-01-01
        • 2023-03-07
        相关资源
        最近更新 更多