在Docker映像中安装Tensorflow时出错 [英] Error installing Tensorflow in docker image
问题描述
我正在尝试为我的应用程序在docker映像中安装tensorflow.
我在用于构建映像的文件夹中有3个文件. Dockerfile
, index.py
和 requirements.txt
>
这些文件的内容是
Dockerfile
从FROM python:alpine3.7复制 ./应用程序WORKDIR/app运行pip3 install -r requirements.txt曝光5000CMD python ./index.py
requirements.txt
tensorflow == 1.1.0scikit学习== 0.18.2scipy == 0.19.1numpy == 1.13.1要求== 2.18.3
index.py
从烧瓶导入烧瓶的 app = Flask(__ name__)@ app.route("/")def hello():返回"Hello World!"如果__name__ =="__main__":app.run(host ="0.0.0.0",port = int("5000"),debug = True)
我在命令行中导航到Windows计算机中这三个文件所在的文件夹,然后执行命令 docker build --tag my-python-app2.
过一会儿,执行一会儿后,我得到以下错误消息.
C:\ Users \ test \ Downloads \ python-docker2> docker build --tag my-python-app2.将构建上下文发送到Docker守护程序4.096kB步骤1/6:来自python:alpine3.7--->cc07d9ec6532步骤2/6:复制./应用程序--->使用缓存--->600334d62435步骤3/6:WORKDIR/app--->使用缓存--->15208b829606步骤4/6:运行pip3 install -r requirements.txt--->在e202ecdc48ba中运行收集tensorflow == 1.1.0(从-r requirements.txt(第1行))找不到满足tensorflow == 1.1.0要求的版本(来自-r requirements.txt(第1行))(来自版本:)找不到tensorflow == 1.1.0的匹配分布(来自-r requirements.txt(第1行))命令'/bin/sh -c pip3 install -r requirements.txt'返回非零代码:1
任何人都可以帮忙吗?
我自己找到了答案.我将tensorflow的行更改为 RUN python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl Dockerfile 中的code>,并将其从requirements.txt中删除
I am trying to install tensorflow in docker image for my application.
I have 3 files in the folder which i am using to build image.Dockerfile
, index.py
and requirements.txt
Contents of these files are
Dockerfile
FROM python:alpine3.7
COPY . /app
WORKDIR /app
RUN pip3 install -r requirements.txt
EXPOSE 5000
CMD python ./index.py
requirements.txt
tensorflow==1.1.0
scikit-learn==0.18.2
scipy==0.19.1
numpy==1.13.1
requests==2.18.3
index.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)
I navigate in the commandline to the folder where i have these 3 files in my windows machine and execute the command docker build --tag my-python-app2 .
After a while, after executing a while, i get below error message.
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
Can anyone help on this?
I found the answer myself. I changed the line for tensorflow to RUN python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
in Dockerfile and removed it from requirements.txt
这篇关于在Docker映像中安装Tensorflow时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!