Search code examples
pythondockertensorflowpipdockerfile

Unable to install tensorflow v1 Python package in Docker image


I am trying to install tensorflow<2.0,>=1.15 pip package during the Docker build. I am not able to build it, and I am getting this error in my terminal during the pip installation:

 > [12/12] RUN pip3 install --no-cache-dir -r requirements.txt:                                                                                                                     
#16 0.488 ERROR: Could not find a version that satisfies the requirement tensorflow<2.0,>=1.15 (from versions: none)                                                                
#16 0.489 ERROR: No matching distribution found for tensorflow<2.0,>=1.15   

To replicate the error:

Dockerfile:

FROM python:3.7-slim-buster
RUN apt-get update
RUN apt-get install -y unzip
RUN apt-get install -y build-essential
RUN apt-get install -y python-all-dev
RUN apt-get install -y libexiv2-dev
RUN apt-get install -y libboost-python-dev
RUN apt-get install -y wget

COPY . /usr/src/app
WORKDIR /usr/src/app

ENV PYTHONUNBUFFERED True
RUN pip3 install --upgrade pip
RUN pip3 install --no-cache-dir -r requirements.txt

requirements.txt:

tensorflow>=1.15,<2.0

  • I have tried to build FROM (first line in the Dockerfile) other Python versions, either 3.7 or lower, never newer. Still the same result.
  • I use Docker Desktop for Mac M1 version 4.3.2, Engine version 20.10.11.
  • When I run it on Fedora Linux, I can build it successfully.

I suspect that this can be Docker-related. There might be a difference between Docker Desktop and Docker for Linux. But I might be doing something wrong.

Have some of you folks ever encountered the same error? How did you solve this? Thanks for any tips.


Solution

  • Tensorflow 1.x does not support the Mac M1 chip. It is recommended to install Tensorflow >=2.5 on Mac M1

    Take a look at these release notes from Mac Tensorflow:

    https://github.com/apple/tensorflow_macos/releases