-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building Bazel inside Ubuntu docker on M1 Mac #13925
Comments
Related #11379 |
Bazel 3.x might not build for M1 at all. Moving a newer version and newer tensorflow might be a more time effective path for you than trying to make this work. |
@aiuto have you managed to get newer versions building on m1 macs? |
4.2.x is the first version to support M1 macs. |
@keith I switched to 4.2.1 on my docker container, but I'm still getting the same error while building mediapipe. |
Yes I see the same |
What does I would recommend to not use the installer inside the Docker image - just download and put the correct Bazel binary that you need into /usr/local/bin/bazel. The installer does the same thing just with more self-extracting magic around it that makes it harder to understand what's happening. For x86_64 Linux: Bazel 4.2.1 or Bazel 3.7.2 I think this might be a mismatch of accidentally trying to run an x86_64 version of Bazel inside an arm64 container or the other way round. Note that Docker under macOS uses Linux under the hood, so M1 compatibility of Bazel should not matter here, it's more important to look after Linux arm64 compatibility in this case. |
@philwo thanks for the help! I am currently using an
Earlier I saw the container trying to find |
@vidheyoza Could you try running |
Tried but getting the same error. EDIT: also tried |
Update: Apparently I was using To recap for anyone in the future: if bazel installation doesn't work for any container that you use, try downloading the binary directly into the container and change permissions to it if needed. It might work much better than the installer script that they have for some (but not all) configurations of OS and architecture. |
Excellent, thanks for posting the solution here @vidheyoza! 😊 |
@philwo circling back to this issue, I need Bazel 0.26.2 or lower to install TF 1.14, but it looks like there is no arm64 build for it like the one you mentioned above. Do you think there's an alternative for this? |
Hey, I'm also on an M1 Mac (12.0.1), and trying to build bazel inside Ubuntu 20.04 (x86_64) using docker. I could get it working for Ubuntu arm64 using docker, but I need x86_64 for something I'm doing. I tried installing version 4.2.1 via the installer script, and by downloading the binary directly. Either way, I get the following error message:
Could you please help me with this? |
Hi @RahulRachuri, can you confirm by running and posting the output of |
Sure, this is the output: |
Mhm.. yeah, looks like that should work. :/ I'm sorry, I really don't know what might cause Unfortunately I can no longer use Docker on my Mac since their license change, so I'm not able to reproduce or debug this. Maybe you could raise this as a bug with Docker? |
I see, that makes sense. I will try raising a bug with Docker, thanks for your help! :) |
I fixed this in #14391 The gist is that when running a non-native binary from Docker, docker uses linux's facility for registering handlers for non-native-elf binaries called binfmt_misc to call qemu-user-static to actually execute the non-native binary. When this happens, /proc/self/exe from the Kernel's view is qemu-user-static (and also lives outside the filesystem the container can see). lseek'ing to find the size of this file will fail. The fix is to use a kernel/elf api to get the executing program name. My patch originally tried to just use the AT_EXECFD from the auxv at a lower level, but I suspect that AT_EXECFD also has problems under this mode of execution. Luckily, AT_EXECFN gives us what we're looking for inside docker on alternate platforms as well as when running natively. It should be more reliable than using argv[0] as well. |
Is your fix usable yet @emidln ? I commented there that I'm running into this issue when trying to cross-compile |
Description of the problem / feature request:
Problem building Bazel inside a Ubuntu docker container built for an M1 Mac.
Feature requests: what underlying problem are you trying to solve with this feature?
Docker is designed to be as OS and architecture agnostic as possible while building a container so that development environments are as consistent inside a team as possible, but Docker can only take care of so many aspects of it. I want to build a specific version of MediaPipe that was forked by my team, and so requires Bazel 3.7.2 and Tensorflow 1.14.0 to be installed and running correctly in the container.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
What operating system are you running Bazel on?
Ubuntu docker image running on macOS with M1 processor.
What's the output of
bazel info release
?No output. Bazel builds but gives error when trying to use it to run
bazel build
:Have you found anything relevant by searching the web?
I have looked at repos of Docker for Mac, Tensorflow, Bazel and MediaPipe. There are mentions of it here and there but the solutions are very specific to the issues raised by the users. There is no general solution of making bazel work with Docker images made on M1.
The text was updated successfully, but these errors were encountered: