tensorflow: Cannot run TensorFlow 2.7 in Docker on M1 (Apple Silicon)
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS 12.0 Monterey
- TensorFlow installed from (source or binary): pre-built binary (Docker and pip)
- TensorFlow version (use command below): 2.7
- Python version: 3.8.10
Describe the current behavior
Our team needs to run TensorFlow as part of a larger application in Docker. However, this doesn’t seem possible on an M1 Mac.
For example, if I use the default TF Docker image (for x86-64 only, an ARM64 image is not available):
> docker run -it tensorflow/tensorflow /bin/bash
> python -c "import tensorflow"
The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted
I get the same error when installing from pip on an x86-64 Linux container:
> docker run -it --platform=linux/amd64 python:3.8-buster /bin/bash
> pip install --upgrade pip && pip install tensorflow
> python -c "import tensorflow"
The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted
Ostensibly, this is because the pre-built TensorFlow requires the CPU to support AVX instructions, but this is not supported by Docker / QEMU when emulating an x86-64 container on M1.
Describe the expected behavior
There should be a way to run TensorFlow in Docker on M1! (Without building from source.)
Every other ML/DS library works with on Docker on M1: PyTorch, Scikit-Learn, Numpy, Scipy, etc.
Standalone code to reproduce the issue
See code snippets above.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 22
- Comments: 15 (5 by maintainers)
Got it – personally I’d like to avoid building from source since it complicates our dependency management.
Most other ML libraries work fine out-of-the-box in x86 emulation on M1: PyTorch, Scikit-Learn, Numpy, Scipy, etc. It would be great if TF supported it as well.
Are you satisfied with the resolution of your issue? Yes No