# Unexpected precompilation in Binder based on Docker image

**URL:** <https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473>\
**Category:** General Usage\
**Tags:** question, precompilation, binder\
**Created:** [May 20, 2024, 11:08am UTC](https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473 "2024-05-20T11:08:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [May 20, 2024, 11:08am UTC](https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473/1 "2024-05-20T11:08:40Z")

</div>

I’ve set up a [Dockerfile](https://github.com/goerz-testing/tutorial-oct-workshop-2024/blob/master/Dockerfile) that sets up a Julia (and Python) environment for a tutorial that should run on [https://mybinder.org](https://mybinder.org). The reason I’m using a Dockerfile instead of relying on Binder to set up everything based on the `Project.toml`/`Manifest.toml` is that the setup and precompilation is more than the Binder nodes can handle. Thus, I’m [letting Github CI build the Docker image](https://github.com/goerz-testing/tutorial-oct-workshop-2024/blob/master/.github/workflows/docker-build.yml) and then [Binder uses that pre-built image](https://github.com/goerz-testing/tutorial-oct-workshop-2024/blob/master/.binder/Dockerfile)

In the Docker image, I make sure activate the project (in the home folder) and instantiate it, so that everything should be precompiled. However, when I load the repo in Binder at [Binder](https://mybinder.org/v2/gh/goerz-testing/tutorial-oct-workshop-2024/HEAD), it appears to forget about the precompilation: Open a new terminal inside Jupyterlab, type `julia --project=.`, type `] instantiate`, see that it starts to precompile 432 packages for the next half hour. What gives? There are precompilation files in `~/.julia/compiled`, and there doesn’t seem to be a permissions problem. How or why does Julia decide that it needs to compile again? Any tips for getting around this?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [May 20, 2024, 11:43am UTC](https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473/2 "2024-05-20T11:43:13Z")

</div>

My educated guess is different CPU target, you can set [`JULIA_CPU_TARGET`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_CPU_TARGET) to avoid this:

> <https://github.com/JuliaIPU/JuliaIpuDemo/blob/db72d4b1c4e54ddf1989fcf583ea61fedb4d43d4/Dockerfile#L22-L25>

If you know what CPU Binder runs on, you can use a slightly higher baseline, rather than `generic` (but if you get it wrong, you’re still at the same place).

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [May 20, 2024, 11:58am UTC](https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473/3 "2024-05-20T11:58:55Z")

</div>

That sounds very plausible! Let me give it a try…

Since I can access both a shell and a Julia REPL on Binder: is there any way I can find out what it uses as a CPU? (what would be the most appropriate `JULIA_CPU_TARGET`)

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [May 20, 2024, 12:15pm UTC](https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473/4 "2024-05-20T12:15:00Z")

</div>

`Sys.CPU_NAME`, although that’s not perfect because that name comes from LLVM but the target parsing is done separately inside julia, there may be divergences. Also, consider the possibility that Binder may use a pool of different CPUs, so that getting the ISA of one CPU doesn’t necessarily mean you’ll get something that will work everywhere (this is for example the case on GitHub Actions). If you don’t know _ **for sure** _ what CPUs Binder runs on, `generic` may still be a safer, although slower, option.

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [May 20, 2024, 1:17pm UTC](https://discourse.julialang.org/t/unexpected-precompilation-in-binder-based-on-docker-image/114473/5 "2024-05-20T13:17:15Z")

</div>

It works! Thanks so much!
