0

due to the new licensing policy for conda, we have to use mamba as alternative. I am in the process of migrating my docker files but have issues getting micromamba properly installed. The base docker is as follows

ARG CUDA=11.1.1
FROM nvidia/cuda:${CUDA}-cudnn8-runtime-ubuntu18.04
ARG CUDA

Then I install all curl etc via apt-get. Installation of micromamba is done via

RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
RUN export MAMBA_ROOT_PREFIX=./micromamba  # optional, defaults to ~/micromamba
RUN eval "$(./bin/micromamba shell hook -s posix)"
RUN micromamba activate

during the build I get the following errors;

RUN micromamba activate
 ---> Running in ccee400f407d

'micromamba' is running as a subprocess and can't modify the parent shell.
Thus you must initialize your shell before using activate and deactivate.

    To initialize the current  shell, run:
        $ eval "$(micromamba shell hook --shell=)"
    and then activate or deactivate with:
        $ micromamba activate
    
To automatically initialize all future () shells, run:
    $ micromamba shell init --shell= --prefix=~/micromamba

Supported shells are {bash, zsh, csh, xonsh, cmd.exe, powershell, fish}.

Any advice?

talonmies
  • 70,661
  • 34
  • 192
  • 269

1 Answers1

3

Consider using an image from mambaorg/micromamba. These images all have micromamba installed and some helper scripts that make it easier to activate your environments in different contexts. The images with cuda in the tag are derived from nvidia/cuda images.

If you want a Ubuntu 18.04 image, try:

mambaorg/micromamba:bionic-cuda-11.6.2

or if you are up for something a bit more cutting edge, try:

mambaorg/micromamba:jammy-cuda-12.1.0

Please see the documentation for these image and the corresponding GitHub repo. If you need a base image other than those provided on Dockerhub, then see the instructions for how to add micromamba to other images.

Full disclosure, I am the lead maintainer of the mambaorg/micromamba image series.

Will Holtz
  • 677
  • 5
  • 17
  • I have tried to mambaorg/micromamba:focal-cuda-11.8.0 as base image but apt-get install throws error ```E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)``` – nonresidentalien Apr 14 '23 at 21:13
  • 1
    mambaorg/micromamba defaults to a non-root user. Add a "USER root" line directly before your "RUN apt-get ..." command and then at the end do "USER $MAMBA_USER" after the "RUN apt-get ..." command. – Will Holtz Apr 14 '23 at 21:15
  • The docker RUN command does not seem to find the mamba installs (e.g. pip3), despite ```MAMBA_DOCKERFILE_ACTIVATE=1```. could this be because I ran the micromamba installs as root instead of $MAMBA_USER? – nonresidentalien Apr 17 '23 at 14:23
  • I just tested installing python via micromamba as root, setting `USER $MAMBA_USER` and then doing `ARG MAMBA_DOCKERFILE_ACTIVATE=1` and `RUN pip3 install requests`. It worked for me. Can you please submit an issue with your full Dockerfile over at https://github.com/mamba-org/micromamba-docker – Will Holtz Apr 17 '23 at 14:43
  • Just submitted them on GitHub. Thanks again for your help. – nonresidentalien Apr 17 '23 at 16:25
  • 1
    As I posted on github, your `SHELL ...` statement is clobbering the shell configuration done within `mambaorg/micromamba` – Will Holtz Apr 17 '23 at 17:53
  • Those images are great, but I need other OS's for reasons, so it would be nice to have some guidance on how to make micromamba work in other containers than those. – Ben Farmer Aug 04 '23 at 05:24
  • 1
    @BenFarmer please see https://micromamba-docker.readthedocs.io/en/latest/advanced_usage.html#adding-micromamba-to-an-existing-docker-image – Will Holtz Aug 04 '23 at 21:04