Home > other >  Why TensorFlow CPU 2.7.0 is not found by docker while creating an image?
Why TensorFlow CPU 2.7.0 is not found by docker while creating an image?

Time:12-16

I am building a docker image, using this Dockerfile:

FROM python:3.8-alpine
EXPOSE 5000/tcp
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
CMD [ "python", "./app.py" ]

This is the command I used:

docker build -t my-language-app:1.0 .

And it is giving this error:

[ ] Building 91.5s (9/9) FINISHED
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 32B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for docker.io/library/python:3.8-alpine                                               3.3s
 => [auth] library/python:pull token for registry-1.docker.io                                                      0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 3.71kB                                                                                0.0s
 => [1/4] FROM docker.io/library/python:3.8-alpine@sha256:ae21a996ebe902ddc73cff020202d94cb539c8c4426f67636374b32  0.0s
 => CACHED [2/4] WORKDIR /app                                                                                      0.0s
 => [3/4] COPY . /app                                                                                              2.0s
 => ERROR [4/4] RUN pip install -r requirements.txt                                                               86.1s
------
 > [4/4] RUN pip install -r requirements.txt:
#9 5.199 Collecting Flask==1.1.2
#9 5.529   Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
#9 8.898 Collecting numpy
#9 8.978   Downloading numpy-1.21.4.zip (10.6 MB)
#9 64.97   Installing build dependencies: started
#9 84.51   Installing build dependencies: finished with status 'done'
#9 84.51   Getting requirements to build wheel: started
#9 85.15   Getting requirements to build wheel: finished with status 'done'
#9 85.15     Preparing wheel metadata: started
#9 85.64     Preparing wheel metadata: finished with status 'done'
#9 85.88 ERROR: Could not find a version that satisfies the requirement tensorflow-cpu==2.7.0 (from versions: none)
#9 85.88 ERROR: No matching distribution found for tensorflow-cpu==2.7.0
#9 85.89 WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
#9 85.89 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
------
executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1

Why it can't find tensorflow-cpu==2.7.0, when this TensorFlow version is available. What's wrong?

Here is my requirements.txt:

Flask==1.1.2
numpy
tensorflow-cpu==2.7.0

What is not working:

  1. Just writing tensorflow in requirements.txt is also not working.
  2. Removing tensorflow from requirements.txt and adding this RUN python3.8 -m pip install tensorflow command on Dockerfile, also not working.
  3. Running this command in Dockerfile pip3 install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.7.0-cp39-cp39-win_amd64.whl also not working.
  4. Changing Python version in Dockerfile FROM python:3.8-alpine to 3.9, 3.7, 3.6 not working.

CodePudding user response:

Using python:3.7.3-stretch instead of python:3.8-alpine has worked for me

FROM python:3.7.3-stretch
RUN mkdir /app
WORKDIR /app
COPY . .
RUN python -m pip install --upgrade pip
RUN pip install -r requirements.txt
CMD [ "python", "./app.py" ]
  • Related