【问题标题】:Install PyTorch from requirements.txt从 requirements.txt 安装 PyTorch
【发布时间】:2020-07-09 18:30:02
【问题描述】:

Torch 文档说使用

pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

安装最新版本的 PyTorch。这在我手动执行时有效,但是当我将其添加到 req.txt 并执行 pip install -r req.txt 时,它会失败并显示 ERROR: No matching distribution

编辑:从 req.txt 中添加整行并在此处出错。

torch==1.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.htmltorch==1.4.0+cpu
ERROR: Could not find a version that satisfies the requirement torch==1.4.0+cpu (from -r requirements.txt (line 1)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0)
ERROR: No matching distribution found for torch==1.4.0+cpu (from -r requirements.txt (line 1))

【问题讨论】:

  • 你的python版本是多少?
  • @NilankaManoj python 版本:3.6.9

标签: python pip pytorch requirements.txt


【解决方案1】:

在torch之前的requirements.txt中添加--find-links

--find-links https://download.pytorch.org/whl/torch_stable.html

torch==1.2.0+cpu

来源:https://github.com/pytorch/pytorch/issues/29745#issuecomment-553588171

【讨论】:

    【解决方案2】:
    -f https://download.pytorch.org/whl/torch_stable.html 
    torch==1.4.0+cpu 
    -f https://download.pytorch.org/whl/torch_stable.html
    torchvision==0.5.0+cpu
    

    对我来说很好:)

    【讨论】:

      【解决方案3】:

      你可以这样做:

      $pip install -r req.txt --find-links https://download.pytorch.org/whl/torch_stable.html

      只需将您的 PyTorch 要求放在 req.txt 中,如下所示:

      torch==1.4.0+cpu

      torchvision==0.5.0+cpu

      【讨论】:

      • 为什么我的回答被否决了?这个方法你可以试试。
      • OP 可能无法使用除pip install -r req.txt 之外的任何其他命令。我有同样的问题; pip install -r requirements.txt 由另一个团队运营,而不是我;我只能控制 requirements.txt 的内容。
      猜你喜欢
      • 2021-06-28
      • 2020-03-25
      • 2015-03-25
      • 2015-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多