windows - 在 docker 镜像中安装 TensorFlow 时出错
问题描述
我正在尝试在我的应用程序的 docker 映像中安装 tensorflow。
我用来构建图像的文件夹中有 3 个文件。Dockerfile
,index.py
和requirements.txt
这些文件的内容是
Dockerfile
FROM python:alpine3.7
COPY . /app
WORKDIR /app
RUN pip3 install -r requirements.txt
EXPOSE 5000
CMD python ./index.py
要求.txt
tensorflow==1.1.0
scikit-learn==0.18.2
scipy==0.19.1
numpy==1.13.1
requests==2.18.3
索引.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=int("5000"), debug=True)
我在命令行中导航到我的 Windows 机器中有这 3 个文件的文件夹并执行命令docker build --tag my-python-app2 .
一段时间后,执行一段时间后,我收到以下错误消息。
C:\Users\test\Downloads\python-docker2>docker build --tag my-python-app2 .
Sending build context to Docker daemon 4.096kB
Step 1/6 : FROM python:alpine3.7
---> cc07d9ec6532
Step 2/6 : COPY . /app
---> Using cache
---> 600334d62435
Step 3/6 : WORKDIR /app
---> Using cache
---> 15208b829606
Step 4/6 : RUN pip3 install -r requirements.txt
---> Running in e202ecdc48ba
Collecting tensorflow==1.1.0 (from -r requirements.txt (line 1))
Could not find a version that satisfies the requirement tensorflow==1.1.0 (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for tensorflow==1.1.0 (from -r requirements.txt (line 1))
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1
有人可以帮忙吗?
解决方案
我自己找到了答案。我将 tensorflow 的行更改为RUN python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
in Dockerfile并将其从 requirements.txt中删除
推荐阅读
- c# - System.Reflection.AmbiguousMatchException:“找到不明确的匹配项。”
- android - 在运行时添加多个视图而不会给主线程带来太多负载的正确方法是什么
- image-processing - 使用 chrome 扩展程序处理和编辑 youtube 视频?
- c# - c#unity3d如何获取其他场景的变量信息
- python - 字典从不同的函数访问时返回不同的值
- python - 拟合 Gamma 分布
- python - 使用 pyodbc 连接到 mssql 时用户登录失败
- php - 在事件发生前几个小时运行函数
- haskell - 计算字符串中字符的出现次数
- excel-formula - 是否有公式可以快速自动填充范围内的第一个数字?