-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Specify multiple architectures for Julia to precompile to #2044
Conversation
For amd64 (x86_64), we should specify what specific targets the precompilation should be done for. If we don't specify it, it's *only* done for the target of the host doing the compilation. When the container runs on a host that's still x86_64, but a *different* generation of CPU than what the build host was, the precompilation is useless and Julia takes a long long time to start up. This specific multitarget comes from https://docs.julialang.org/en/v1/devdocs/sysimg/#Specifying-multiple-system-image-targets, and is the same set of options that the official Julia x86_64 build is compiled with. If the architecture the container runs on is different, precompilation may still have to be re-done on first startup - but this *should* catch most of the issues. h/t to https://discourse.julialang.org/t/is-it-possible-to-make-precompilation-portable-for-docker-images-built-with-a-different-cpu/95913 which helped point me towards `JULIA_CPU_TARGET`. Fixes jupyter#2015 for more information
I'm not actually sure how we can test this, since the error occurs when the docker image is built with a certain CPU but then run with a different CPU. |
I tested this locally and seemed ok. I think the way out here is to build this out on GitHub actions again, push and then we can test on our local x86s's :) |
There is a better way. To load the image, after unzipping the file, use a command like this: This is a benefit of our upload/download architecture - many things can be checked before merging to main. |
@yuvipanda waiting for you to check the image in the PR on your x86_64 machine. |
Do you maybe know how to fix this when running aarch64 images on Apple Silicon Macs? I think the important file to look at is this one: https://github.com/JuliaLang/julia/blob/master/base/cpuid.jl Disclaimer: this is the first time I look at the source code of Julia, so maybe we need to take a look at other file(s). |
Yep, the ISAs mentioned in the docs were added 5 years ago, so the documentation is outdated. I suggest we resolve this issue for the modern CPUs as well, and also add a link for a |
I also have an idea in the opposite direction - stop trying to deal with this on the build machine at all. We want To do this, we can use (wait for it) Pros:
Cons:
My opinion on this - if we can fix this issue in a sustainable way and for modern CPUs as well (I'm okay with manual updates of JULIA_CPU_TARGET, but we need to have a clear understanding how and when to update it), let's do it (users will be more happy. If we can't - then it's better to be fixed during runtime. |
@mathbunnyru These are the targets settings for all the architectures: https://github.com/JuliaCI/julia-buildkite/blob/70bde73f6cb17d4381b62236fc2d96b1c7acbba7/utilities/build_envs.sh#L20-L76 Original post: docker-library/julia#79 (comment) File: https://github.com/JuliaCI/julia-buildkite/blob/main/utilities/build_envs.sh |
Great, thanks! |
- Don't need `export` as this is only used within this script - Steal from upstream what should be setup for aarch64
Quietens pre-commit
That's a great find, thanks @benz0li! While newer architectures do exist in |
@yuvipanda Likewise. #2015 (comment) ff is exemplary in finding out the cause.
Your assumption is correct. |
Ok, testing on aarch64:
success! And fine on x86_64 too!
yay! I think this means this is ready to merge, @mathbunnyru. |
Sounds good to me. |
The compliment in #2044 (comment) made my day brighter, thanks @benz0li :) |
I also tested on my M2 MacBook Air, and it only takes Amazing work both @yuvipanda and @benz0li, thank you! |
Thanks for the review and merge, @mathbunnyru. In addition, thanks for setting up the build process in such a way I could actually test the built images without having to merge these! |
I also wrote a quick blog post about this so this information is easier to find for the next soul that goes searching: https://words.yuvi.in/post/pre-compiling-julia-docker/ |
Describe your changes
For amd64 (x86_64), we should specify what specific targets the precompilation should be done for. If we don't specify it, it's only done for the target of the host doing the compilation. When the container runs on a host that's still x86_64, but a different generation of CPU than what the build host was, the precompilation is useless and Julia takes a long long time to start up. This specific multitarget comes from
https://docs.julialang.org/en/v1/devdocs/sysimg/#Specifying-multiple-system-image-targets, and is the same set of options that the official Julia x86_64 build is compiled with. If the architecture the container runs on is different, precompilation may still have to be re-done on first startup - but this should catch most of the issues.
h/t to
https://discourse.julialang.org/t/is-it-possible-to-make-precompilation-portable-for-docker-images-built-with-a-different-cpu/95913 which helped point me towards
JULIA_CPU_TARGET
.Issue ticket if applicable
Fixes #2015 for more information
Checklist (especially for first-time contributors)