skip to Main Content

I’m trying to run some projects using the new Mac M1. Those projects already work on Intel processor and are used by other developers that use Intel.

I am not able to build this simple Dockerfile:

FROM python:3.9

RUN python -m pip install --upgrade pip

RUN pip install tensorflow==2.6.2

I get this message:

 > [3/3] RUN pip install tensorflow==2.6.2:                                                                                                            
#6 0.583 ERROR: Could not find a version that satisfies the requirement tensorflow==2.6.2 (from versions: none)                                        
#6 0.583 ERROR: No matching distribution found for tensorflow==2.6.2  

I am able to install tensorflow locally, outside of the Dockerfile. Also, friends are able to build this image from their intel Mac.

I even tried to run docker build com different console architectures: i386 and arm64, but none work.

Any suggestions?

3

Answers


  1. EDIT: you may want to check menrfa’s answer by looking at https://github.com/KumaTea/tensorflow-aarch64


    The package tensorflow is not available for armv8.

    I’ll guessing your local python is running using rosetta2 (intel x86_64).
    You can check that using:

    python3 -c "import platform; print(platform.machine())"
    x86_64
    

    The solution is forcing Docker to build that image for x86_64 also.
    It’s easy. Just change your Dockerfile to:

    FROM --platform=linux/x86_64 python:3.9
    
    RUN python -m pip install --upgrade pip
    
    RUN pip install tensorflow==2.6.2
    

    Or, if you do not want to change your Dockerfile, you may build that image with:

    docker build --platform linux/x86_64 -t myimage .
    

    post note:

    as [tyrex] said in a comment, although the tensorflow gets installed on the armv8, it will probably fail due to some bugs on the emulation (eg qemu: uncaught target signal 6 (Aborted) - core dumped).

    He solved his requirements using PyTorch instead.

    Login or Signup to reply.
  2. The following works for me. (Chip Apple M1 Pro + MacOS 12.1)

    Docker: Debian GNU/Linux 11 (bullseye)

    RUN pip install tensorflow==2.6.0 -f https://tf.kmtea.eu/whl/stable.html
    

    Obviously thanks to https://github.com/KumaTea/tensorflow-aarch64

    Login or Signup to reply.
  3. Tensorflow currently does not provide binaries (.whl files) for linux/arch64 inside docker containers on M1.

    But you can use my prebuilt TensorFlow .whl file for M1:
    https://github.com/diyor28/tf-docker-m1

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search