apple / tensorflow_macos

TensorFlow for macOS 11.0+ accelerated using Apple's ML Compute framework.
Other
3.66k stars 308 forks source link

Is there any way to make tensorflow work on a docker image from a Macbook M1 host ? #164

Open leopons opened 3 years ago

leopons commented 3 years ago

Hi, I just acquired a macbook with the M1 chip.

I can't build my usual docker images that contain tensorflow. I first thought this was a docker problem, but as explained here, it seems that docker just need a tensorflow build for the M1 chip to make it work anyway.

I've tried the venv installation of the M1 tensorflow, it works perfectly.

Is there any way to make it work on a docker image instead of a venv ? I've tried to replace the tensorflow dependency by a manual installation on the Dockerfile :

RUN pip install --upgrade --force --no-dependencies https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha2/tensorflow_macos-0.1a2-cp38-cp38-macosx_11_0_arm64.whl https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha2/tensorflow_addons_macos-0.1a2-cp38-cp38-macosx_11_0_arm64.whl

But this doesn't work, I get ERROR: tensorflow_macos-0.1a2-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform. Maybe because the docker image mimics a non-macos platform ?

Thanks

khirotaka commented 3 years ago

It is not possible to run libraries built for macOS (including TensorFlow) in a Docker container. This is because they are not built for Linux.

Therefore, it is impossible to use the TensorFlow for M1 macOS distributed here with Docker running on M1 Mac.

If you really want to run TensorFlow in a Docker container, you can build TensorFlow for aarch64 Linux from source.

If you have any questions about how to build for Linux, you can ask at the official TensorFlow Issues. At least this is the place to report and resolve issues for macOS.