Search code examples
dockermacosapple-m1mamba

Micromamba install gets stuck when run in docker container on ARM mac


When using micromamba install in an amd64 docker container run on M1 ARM macOS 13.5, the installation hangs indefinitely after the extraction step.

The following docker file, built with

docker build . --platform linux/amd64
FROM mambaorg/micromamba:1.4.9
COPY environment.yml /environment.yml
RUN micromamba create -vv -y -n pangolin -f /environment.yml
...
#7 20.14   Install: 117 packages
#7 20.14 
#7 20.14   Total download: 192MB
─────────────────────────────────────────────────────────────────────────────────────────
#7 20.14 Transaction starting

In info log, one can see a bit more (new run hence different timings):

#7 21.54 info     libmamba Transfer done for 'coin-or-clp'
#7 21.54 info     libmamba Transfer finalized, status: 200 [https://conda.anaconda.org/conda-forge/linux-64/coin-or-clp-1.17.8-h1ee7a9c_0.conda] 1173622 bytes
#7 21.54 info     libmamba Download finished, validating '/opt/conda/pkgs/coin-or-clp-1.17.8-h1ee7a9c_0.conda'

This is what happens in debug (again different run hence ignore relative timing):

#7 28.93 debug    libmamba Running in-process extraction for '/opt/conda/pkgs/git-lfs-3.4.0-ha770c72_0.conda'
#7 29.03 debug    libmamba Extracted to '/opt/conda/pkgs/mpi-1.0-openmpi'
#7 29.03 debug    libmamba Decompressing '/opt/conda/pkgs/connection_pool-0.0.3-pyhd3deb0d_0.tar.bz2'
#7 29.03 debug    libmamba Running subprocess extraction '/bin/micromamba package extract /opt/conda/pkgs/connection_pool-0.0.3-pyhd3deb0d_0.tar.bz2 /opt/conda/pkgs/connection_pool-0.0.3-pyhd3deb0d_0'

There is absolutely no progress hereafter, even after 10 minutes. How can I fix this?


Solution

  • This appears to be due to a known QEMU issue combined with mamba's use of subprocesses. The interaction of QEMU and mamba was discussed extensively in this mamba issue. The solution that worked for me was to run the following before any mamba install or mamba create:

    micromamba config set extract_threads 1
    

    i.e. modifying the Dockerfile as follows:

    FROM mambaorg/micromamba:1.4.9
    COPY environment.yml /environment.yml
    RUN micromamba config set extract_threads 1 # <---- This is the added line that fixes it
    RUN micromamba create -vv -y -n pangolin -f /environment.yml
    

    The bug may be stochastic as it depends on multiple processes being used. If you're "lucky" you might avoid the bug most of the time.