【问题标题】:Docker build ERROR: Could not find a version that satisfies the requirement torch==1.5.1Docker build ERROR: 找不到满足要求的版本torch==1.5.1
【发布时间】:2021-01-23 15:48:17
【问题描述】:

我有一个格式如下的 Dockerfile:

FROM python:latest
ADD requirements.txt .
RUN pip3 install -r requirements.txt
CMD ["python", "script.py"]

我的 requirements.txt 如下所示:

grpcio==1.31.0
grpcio-tools==1.31.0
torch==1.5.1

当我执行docker image build . 时,出现以下错误:

Sending build context to Docker daemon  61.44kB
Step 1/7 : FROM python:latest
 ---> dfc47c6cee13
Step 2/7 : ADD requirements.txt .
 ---> Using cache
 ---> 3be914d5b849
Step 3/7 : RUN pip3 install -r requirements.txt
 ---> Running in 372c329c76fa
Collecting grpcio==1.31.0
  Downloading grpcio-1.31.0.tar.gz (20.0 MB)
Collecting grpcio-tools==1.31.0
  Downloading grpcio-tools-1.31.0.tar.gz (2.1 MB)
ERROR: Could not find a version that satisfies the requirement torch==1.5.1 (from -r requirements.txt (line 3)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.5.1 (from -r requirements.txt (line 3))
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

这是一个奇怪的错误,因为如果我没记错的话,torch 能够在最近(早在 2 周前)安装,所以我不确定为什么会发生这种情况。

【问题讨论】:

    标签: docker dockerfile pytorch torch torchvision


    【解决方案1】:

    我通过更改 Dockerfile 中的版本而不是这样做解决了这个问题

    FROM python:latest
    

    改成

    FROM python:3.7.4
    

    我认为torch 在安装python3.9.0 时存在问题,这就是python:latest 几天前更新的内容。最好强制 docker 容器使用特定的已知版本:)

    【讨论】:

      猜你喜欢
      • 2019-10-07
      • 2020-03-13
      • 1970-01-01
      • 2019-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多