无法在 windows 中通过诗歌安装 torchvision

Cannot install torchvision via poetry in windows

感谢这里的回答,我成功安装了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.

我用谷歌搜索了一下,找到了一些 'just pip install torchvision' 的答案。 但我怀疑它是否有效,因为根据 PyPi(https://pypi.org/project/torchvision/#files),windows 没有 wheel 文件。我试过了,结果如我所料失败了。

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

  1. https://download.pytorch.org/whl/torch_stable.html 中查找您要安装的版本(torchvision 版本、python 版本、CUDA 版本、OS 等)
  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,您应该可以开始了。

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