-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
native image build gets stuck #16225
Comments
Hello, you can try to use RemoveSaturatedTypeFlows option to your build, you'll need less memory and probably needs less GC. |
@machi1990 [INFO] Scanning for projects... it gets stuck after that. Note that the image that was used is |
@vietk what I need to do exactly ? |
Sorry for the non detailled answer : For example, you can modify the native profile in your pom.xml
Hope it could helps achieving your build ... Regards |
@vietk @machi1990 it didn't work, and I tried to run this command ./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.container-runtime=docker, but It got stuck again. Note that I am using the new MacBook m1. |
I noticed something weird that although the memory max usage is 16gbyte, the memory usage gets stuck after a while. The below data appears after using the command docker stats. CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O |
I'm not sure if that architecture is currently supported by Graal VM/native-image. It's only recently that the base OpenJDK itself added support for this openjdk/jdk#2200. |
The native build is running into a docker container, so as long as docker is supported on M1, it should be working. @mutasemhidmi Maybe you can add also this option to your build to have more information of the native compilation
by updating the native profile :
|
@vietk I am just trying quarkus lambda example, the one with greeting class. I wanted to ask something is there any difference between using ./mvnw package -Pnative -Dquarkus.native.container-build=true and ./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.container-runtime=docker. Note that both are giving me the same results, but as I understood the second one does not use GraalVM |
Is this a Macbook m1 issue or Quarkus ? |
No, both commands will do exactly the same. |
I think the problem is coming from the fact that this image is for linux/amd64 and not arm64. I built a graalvm arm64 docker image using https://github.com/graalvm/container/tree/master/community. Now, the build doesn't get stuck, but when I run sam local invoke for my lambda, I get the below error. msg="Init failed" InvokeID= error="fork/exec /var/task/bootstrap: no such file or directory" Note that I unzipped function.zip, and I found the bootstrap file there. |
I use m1 macbook air,encountered the same problem as you.but I use windows build native image with docker successed. Even the |
@suzihao any idea where is the problem coming from? At first, I thought that it's coming from the image because its type is amd64. |
|
I'm using a Mac Mini M1 and I have the same error when I try to build native image. I think that it is related with this message:
Shouldn't this image quarkus/ubi-quarkus-native-image be available to linux/arm64/v8? |
Hello @mutasemhidmi, @suzihao Furthermore, native builds with Graal are not supported on Darwin (mac) aarch64 oracle/graal#2666. Only Linux aarch64 are supported with both Graal and Mandrel (since mandrel-21.3.0.0-Fina ). Depending on what your container engine is capable of, it might be the case that your aarch64 Mac host could host an amd64 Linux container, but the question is entirely outside the scope of Quarkus. @famod I think this should be closed unless clarified. |
Hello @mutasemhidmi @suzihao @stachera , As a workaround, you can build your own builder-image from graalvm-ce image. Graalvm-ce images are available for both platforms: linux/amd64 and linux/arm64 Generate a Dockerfile under src/main/docker/Dockerfile.graalbase FROM ghcr.io/graalvm/graalvm-ce:latest AS build
RUN gu install native-image
WORKDIR /project
VOLUME ["/project"]
ENTRYPOINT ["native-image"] Build this docker file docker build -f src/main/docker/Dockerfile.graalbase -t graalbase . Add builder-image to application.properties quarkus.native.builder-image=graalbase Build executable: ./mvnw clean install -Pnative -Dquarkus.native.container-build=true Credits goes to Armin Vogt: https://www.youtube.com/watch?v=IYUQ1tCHkNI&ab_channel=ArminVogtcloud-nativeplaylists |
@knuspertante I tried the same exact solution before, but the build got stuck also. |
@mutasemhidmi which docker installation do you use? I use Docker Desktop for Apple Silicon |
It works fine for me, thanks |
Works for me as well. I noticed that the AMD64 image on Docker Desktop only used 2 cores while 4 cores were configured for Docker. Using the ARM image and 6 configured cores, it went super fast. |
with recent quarkus kickstrat we get the following docker images which are only for amd64 so we need to change to redhat/ubi-minimal or build a distroless with arm64 libraries quay.io/quarkus/quarkus-distroless-image - only available for amd64only available for amd64 Rest the solution works fine in my mac mini 16Gb i have 6 cores to docker and 6GB ram so build completes ~ 4-5min. |
My environment: MacOS: 12.1 Monterey Followed the steps in: #16225 (comment) in order to build the native image. Then I deployed the lambda in localstack by using serverless: serverless file:
Then when I invoked the lambda in integration tests and got the following error:
As a fun fact: I built the native image in an Intel chipset MacBook and copied the generated function.zip in target/ in my M1 MacBook, then deployed the lambda native image using serverless and that way I could run the lambda seamlessly. @mutasemhidmi have you been able to run the lambda in your M1 MacBook? Did you overcome the problem I specified above? |
If you are using macOS Catalina and later you may need to remove the quarantine attribute from the bits before you can use them $ sudo xattr -r -d com.apple.quarantine path/to/graalvm/folder/ |
Please share if anyone has a working solution. Specifically, my problem is cross-compile build - build amd64 on Apple arm. I've tried to use the correct image runtime with
I also checked on of building locally with GraalVM with cross-compile, but Graal does not support this oracle/graal#407 |
For arm/arm64 platform, change the image version in src/main/docker/Dockerfile.native-micro to "2.0-arm64" Generate docker image: Finally, run: Tested on quarkus-quickstarts/getting-started |
Has anyone worked this out or is this still an open issue? I've been trying to build a amd64 native app on my Apple M1 using the following command: However, the build gets stuck. How do I build a amd64/linux based native app and docker image on my M1? Any help would be appreciated! |
@eistropfen, I used this config |
@xiaodong-xie thank you for your reply. Are you able to tell me which builder image you are using? I've added your suggested config (
produces an arm64 / aarch64 runner file
Prints
but then gets stuck in the
|
@eistropfen, there is no cross compilation for native images yet (based on the discussion of this issue), adding |
I have this problem too on docker desktop under OS Windows 11, building stuck on this lines
With this, also CPU used for 100% and disk usage also is 100%. |
Today I fixed the problem, with this configuration: build.gradle.kts: quarkus {
cacheLargeArtifacts.set(true)
}
tasks.quarkusBuild {
nativeArgs {
"quarkus.native.container-runtime" to "docker"
"additional-build-args" to "-H:+RemoveSaturatedTypeFlows,-H:+PrintAnalysisStatistics,J-enable-preview"
}
} application.properties quarkus.docker.buildx.platform=linux/amd64 Dockerfile: ## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:22.3.1-java19 AS build
USER root
RUN microdnf install findutils
COPY --chown=quarkus:quarkus gradlew /code/gradlew
COPY --chown=quarkus:quarkus gradle /code/gradle
COPY --chown=quarkus:quarkus build.gradle.kts /code/
COPY --chown=quarkus:quarkus settings.gradle.kts /code/
COPY --chown=quarkus:quarkus gradle.properties /code/
USER quarkus
WORKDIR /code
COPY src /code/src
RUN ./gradlew build -Dquarkus.package.type=native -Dquarkus.log.level=INFO -x test
## Stage 2 : create the docker final image
FROM quay.io/quarkus/quarkus-micro-image:2.0
WORKDIR /work/
COPY --from=build /code/build/*-runner /work/application
RUN chmod 775 /work
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] But, there are still problems when the build hangs, but this has become much less common. |
Closing this as it is quite old and convoluted. Since this issue was opened Quarkus builder images have become multiplatform and now work on aarch64 as well (quarkusio/quarkus-images#195) and GraalVM/Mandrel has improved Apple M support. Please create a new issue if needed. |
native image build gets stuck. I have macbook m1 and I am using docker to build a native image by runninag the below command. Note that I increased the memory in docker desktop and in the pom.xml
./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.native-image-xmx=16g
The text was updated successfully, but these errors were encountered: