docker - Docker build ERROR: 找不到满足要求的版本torch==1.5.1
问题描述
我有一个具有以下格式的 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 周前)安装,所以我不确定为什么会发生这种情况。
解决方案
我通过更改 Dockerfile 中的版本而不是这样做来解决这个问题
FROM python:latest
将其更改为
FROM python:3.7.4
我认为torch 在安装python3.9.0 时存在问题,这就是python:latest 几天前更新的内容。最好强制 docker 容器使用特定的已知版本:)
推荐阅读
- typescript - 在嵌套数组打字稿中使用动态名称访问数组
- java - 如何以 ISO8601 格式将 Spring Boot 解析属性绑定到 LocalTime?
- linux - ./graph_rules.sh:第 86 行:2:未绑定的变量 - 无法使这项工作
- django - Django 使用单个查询对注释百分比进行分组
- php - 将 Blob 存储的图像从数据库导出到 php 中的 excel 工作表
- c# - 如何结束无限循环的后台线程
- r - 将函数应用于条件行,并在 R 中的新列中输出
- c# - 从网络核心中的触摸屏接收 RawInput
- ios - Xamarin.Forms:TabbedPage 图标在 Android 上很好,但在 iOS 上太大了
- spring-boot - 将带有 H2 DB 的 SpringBoot 部署到 Heroku