-
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
Bazel does not run in emulated docker environment #11379
Comments
@travisgroth Just to understand this correctly, as I never used binfmt/qemu docker emulation for arm64 - you run these steps on an x86_64 VM? |
Works on my machine. I had to add
Other than that, I was able to compile bazel this way and build bazel-buildfarm without problems on my machine (there aren't any targets in //, so that completes quickly, but I was actually able to build real targets afterwards).
I used
NB. I saw the error NB. That
|
@philwo Yes - to be specific, I'm on a Linux x86_64 VM running the build inside an ARM64 container. This is using the @jiridanek that's extremely strange. Can you share the sha of the qemu-user-static image you used? |
@travisgroth I just downloaded it. I got excited about this possibility to get aarch64 quickly and conveniently.
edit: I can even set this up without using
|
Yes..it's nice when it works :| I'll go back over my setup again. |
Okay, I was able to narrow it down to the Working commands: apt-get install docker.io
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build -t bazel -f Dockerfile . $ docker run -it bazel /bazel/output/bazel
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
... still trying to connect to local Bazel server after 10 seconds ...
[bazel release 3.1.0- (@non-git)]
Usage: bazel <command> <options> ...
Available commands:
analyze-profile Analyzes build profile data.
aquery Analyzes the given targets and queries the action graph.
build Builds the specified targets.
canonicalize-flags Canonicalizes a list of bazel options.
clean Removes output files and optionally stops the server.
coverage Generates code coverage report for specified test targets.
cquery Loads, analyzes, and queries the specified targets w/ configurations.
dump Dumps the internal state of the bazel server process.
fetch Fetches external repositories that are prerequisites to the targets.
help Prints help for commands, or the index.
info Displays runtime info about the bazel server.
license Prints the license of this software.
mobile-install Installs targets to mobile devices.
print_action Prints the command line args for compiling a file.
query Executes a dependency graph query.
run Runs the specified target.
shutdown Stops the bazel server.
sync Syncs all repositories specified in the workspace file
test Builds and runs the specified test targets.
version Prints version information for bazel.
Getting more help:
bazel help <command>
Prints help and options for <command>.
bazel help startup_options
Options for the JVM hosting bazel.
bazel help target-syntax
Explains the syntax for specifying targets.
bazel help info-keys
Displays a list of keys used by the info command. |
I'm running into this exact issue using a chroot with EDIT: strangely, following the docker instructions appears to have fixed
|
I'm seeing the same on a Debian sid riscv64 QEMU build of docker-image-debian-bootstrap. It sounds a bit like a partial regression of a QEMU bug from 2014. Unfortunately, I haven't had time to research it. I did check |
I'm running into same error on m1-chip Macbook and docker buildx to create amd64 image. FROM golang:1.16 as builder
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
apt-transport-https \
curl \
g++ \
gnupg \
pkg-config \
python \
software-properties-common \
unzip \
zip \
zlib1g-dev
RUN curl -LO https://github.com/bazelbuild/bazel/releases/download/4.0.0/bazel-4.0.0-linux-x86_64 && \
mv ./bazel-4.0.0-linux-x86_64 /usr/local/bin/bazel && \
chmod +x /usr/local/bin/bazel
# RUN sed -i 's@/proc/self/exe@/usr/bin/bazel@' /usr/local/bin/bazel
# RUN mv /usr/local/bin/bazel /usr/bin/bazel
RUN bazel version $ docker buildx build --platform linux/amd64 -t my-bazel-image --progress --load .
WARN[0000] No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
#1 [internal] load build definition from Dockerfile
#1 sha256:6ba7a01ddddf53414fc03e0ce6cbb9af13d641fb8f1dc462bddcdc411f48e974
#1 transferring dockerfile: 30B 0.0s
#1 transferring dockerfile: 2.17kB 0.0s done
#1 DONE 0.4s
...
#7 [4/4] RUN bazel version
#7 sha256:9086214ac451e86e191f6ba254184c016c6f21a951216faa89a970e1d40fa7e0
#7 0.802 Opening zip "/proc/self/exe": lseek(): Bad file descriptor
#7 0.802 FATAL: Failed to open '/proc/self/exe' as a zip file: (error: 9): Bad file descriptor
#7 ERROR: executor failed running [/bin/sh -c bazel version]: exit code: 36 This error also happen on GCP's docker image on my environment. FROM gcr.io/cloud-builders/bazel
RUN bazel version ref: https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/bazel Then I tried the uncomment sed lines on Dockerfile, (ref: PINTO0309/Bazel_bin#2 ) #10 [6/6] RUN bazel version
#10 sha256:2a2b74e6295f688d9f7b65cc031af03adc9ea1cb8b5c0b916cf482471d4233d3
#10 0.809 Extracting Bazel installation...
#10 29.07 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#10 29.08 Segmentation fault
#10 ERROR: executor failed running [/bin/sh -c bazel version]: exit code: 139 my environemnt$ sw_vers
ProductName: macOS
ProductVersion: 11.2.1
BuildVersion: 20D74
$ /usr/bin/arch
arm64
# Using Docker Desktop RC 3 (2021-04-01)
# https://docs.docker.com/docker-for-mac/apple-m1/
$ docker --version
Docker version 20.10.5, build 55c4c88 How to create libtensorflowlite_c.so without bazel(This is not related with this bazel error, but it might help the people in same situation) I just wanted to build TensorFlow Lite C library FROM golang:1.16 as builder
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
apt-transport-https \
curl \
g++ \
git \
gnupg \
pkg-config \
python \
software-properties-common \
unzip \
zip \
zlib1g-dev
ENV TENSORFLOW_VERSION v2.2.0-rc3
ENV GO_TFLITE_VERSION 30f5e2a268d2eb053f758636609c5c379a3016b5
#== Download
WORKDIR /go/src/github.com
RUN mkdir mattn tensorflow && \
git clone https://github.com/mattn/go-tflite.git ./mattn/go-tflite && \
git clone --depth 1 -b ${TENSORFLOW_VERSION} https://github.com/tensorflow/tensorflow.git ./tensorflow/tensorflow && \
cp mattn/go-tflite/Makefile.tflite tensorflow/tensorflow/tensorflow/lite/c/Makefile
#== Build
WORKDIR /go/src/github.com/tensorflow/tensorflow
RUN ./tensorflow/lite/tools/make/download_dependencies.sh && \
make -f ./tensorflow/lite/tools/make/Makefile
WORKDIR /go/src/github.com/tensorflow/tensorflow/tensorflow/lite/c
RUN make
RUN mkdir -p /usr/local/include/tensorflow/lite/c && \
cp libtensorflowlite_c.so /usr/local/lib/ && \
cp *.h /usr/local/include/tensorflow/lite/c/ && \
cp ../*.h /usr/local/include/tensorflow/lite/
FROM golang:1.16
COPY --from=builder /usr/local/lib/libtensorflowlite_c.so /usr/local/lib/libtensorflowlite_c.so
COPY --from=builder /usr/local/include/tensorflow /usr/local/include/tensorflow
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/lib
# To avoid error 'could not determine kind of name for C.TfLiteInterpreterOptionsSetUseNNAPI'
ENV GO_TFLITE_VERSION 30f5e2a268d2eb053f758636609c5c379a3016b5
WORKDIR /go/src/github.com/mattn
RUN git clone https://github.com/mattn/go-tflite.git && \
cd go-tflite && \
git checkout ${GO_TFLITE_VERSION}
WORKDIR /go/src/github.com/mattn/go-tflite/_example/fizzbuzz
RUN go run ./main.go |
I resolved this issue by re-running Recently I created the docker user group and setup the permissions necessary to run docker without |
I think this issue, at least related to running in docker on M1 machines, still exists |
This is fixed in #14391 |
it also helped me as well, i added ubuntu user into docker group to run docker commands without sudo |
Description of the problem / feature request:
When using binfmt/qemu docker emulation for arm64, bazel can build itself, but cannot run the resulting binary.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Dockerfile:
What operating system are you running Bazel on?
What's the output of
bazel info release
?Built from 3.1.0 dist tarball
If
bazel info release
returns "development version" or "(@non-git)", tell us how you built Bazel.See repro steps. Compiled in container.
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?N/A
Have you found anything relevant by searching the web?
This looks related to #7135 but that was closed with #10761, and I'm not clear on why.
Any other information, logs, or outputs that you want to share?
It is worth noting that I do not observe this behavior on an older system:
The text was updated successfully, but these errors were encountered: