Micromamba

Micromamba is a standalone version of Mamba which is an alternative to Conda. This stack delivers a custom anaconda/miniconda type deployment based on the communities conda-forge channel with micromamba as the package manager. For more information visit micromamba documentation

How to Install Micromamba?

SStack tool allows you to install micromamba, and use it to install software in your desired location. For example, to install micromamba named 2022A in your home directory, run:

sstack install -t micromamba -n 2022A

This creates a module file that you can load in your environment to be able to use the micromamba to manage software, as shown in the following:

module use "/home/tahat/sstack/modules"
module load micromamba/2022A

To check if micromamba is now available and you can use it, run the following command:

micromamba --version

Output

0.24.0
micromamba has conflicts with conda, Spack and EasyBuild. This means that you can not load micromamba with any of those stacks at the same time.

How to Use Micromamba to Manage Software?

After loading the appropriate module, you can run install to add new packages to the environment. For example, to install xtensor run:

micromamba install xtensor

Now you can check if the software is available by running:

micromamba list xtensor

Output

List of packages in environment: "/home/tahat/sstack/stacks/micromamba/2022A"

  Name     Version  Build       Channel
─────────────────────────────────────────────
  xtensor  0.24.2   h924138e_0  conda-forge

Create Virtual Environmnet

micromamba allows you to create a new virtual environment. The simplest way you can create a new micromamba environment is like so:

micromamba create -n <env-name>

For example, to create an environment named my_env, run:

micromamba create -n my_env

You can check all available environmnets by running:

micromamba env list

Output

  Name    Active  Path
────────────────────────────────────────────────────────────────────────────
  base    *       /home/tahat/sstack/stacks/micromamba/20222A
  my_env          /home/tahat/sstack/stacks/micromamba/20222A/envs/my_env

The above output shows that my_env is available, and you are currently in base environment.

Create a Module for Virtual Environment

Once you create the environmnet, you can create a module file for it. This will add the environment to the module system where you can load it in your enviroument. A module named base was created when micromamba stack was installed. To see if the base module is available, run:

module avail base

----------------------------------------------------- /home/tahat/sstack/stacks/micromamba/20222A/modules ------------------------------------------------------
   base

Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".

(1) Automatically Generate Module Files

In addition to base, you can create module files for other environments by updating your SStack Conda with a --du flag. In this case, modulefiles will be created automatically.

Syntax

sstack update [OPTIONS]
  • OPTIONS:

    • Required:

      • -t or --type: Type of stack (here it should be conda).

      • -n or --name: Name of stack (test-conda/ my-SStack-conda / etc..).

      • --du Don’t Update Stack Software.

For example:

sstack update -t micromamba -n test-mamba --du

Output

micromamba/test-mamba: Sucessfully Regenerated Module File!

+------------+------------+---------+------------------------------------------+
| Name       | Type       | Version | Path                                     |
+------------+------------+---------+------------------------------------------+
| test-mamba | micromamba | 1.5.8   | /fs1/home/yuxiwang/sstack/rhel_8/stacks/ |
|            |            |         | micromamba/test-mamba                    |
+------------+------------+---------+------------------------------------------+

Module Setup/Load Commands:

module use "/fs1/home/yuxiwang/sstack/rhel_8/modules"
module load micromamba/test-mamba

After that, you can check if the modules are ready by:

module avail

To see the module for conda environmnet, conda needs to be loaded. In my example, conda/test-conda is loaded before using module avail.

Output

-------------------------------------- /fs1/home/yuxiwang/sstack/rhel_8/stacks/micromamba/test-mamba/modules --------------------------------------
   base    my_env

-------------------------------------- /fs1/home/yuxiwang/sstack/rhel_8/modules --------------------------------------
   conda/test-conda    micromamba/test-mamba (L)    spack/my_spack    spack/test-spack_2    spack/test-spack

-------------------------------------- /fs1/software/sstack/rhel_8/modules --------------------------------------
   conda/2022a    conda/2023a    conda/2024a (D)    custom/2022a    custom/2023a    custom/2024a (D)    spack/2022a    spack/2023a (D)    sstack/main (L)

-------------------------------------- /etc/modulefiles --------------------------------------
   pmix/2.2.5    pmix/3.2.3    pmix/4.1.2 (D)

-------------------------------------- /fs1/software/sstack/modules --------------------------------------
   os/centos_7_test (S)    os/centos_7 (S)    os/rhel_8_test (S)    os/rhel_8 (S,L,D)

-------------------------------------- /usr/share/lmod/lmod/modulefiles/Core --------------------------------------
   lmod    settarg

  Where:
   S:  Module is Sticky, requires --force to unload or purge
   L:  Module is loaded
   D:  Default Module

If the avail list is too long consider trying:

"module --default avail" or "ml -d av" to just list the default modules.
"module overview" or "ml ov" to display the number of modules for each name.

Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".

(2) Manually Generate Module Files

You can also manually create the modulefiles.

You need to create module file having the same name of your created environmnet in the same path of base module file (base.lua). To find where to add the module file and what contents you need to add to it, run:

module --raw show base

Output

------------------------------------------------------------------------------------------------------------------------------------------------------------
   /home/tahat/sstack/stacks/micromamba/20222A/modules/base.lua:
------------------------------------------------------------------------------------------------------------------------------------------------------------
help([[For help contact hpc-team@nmsu.edu]])
whatis([[Name : Micromamba Base Env]])
whatis([[Version: Latest]])
whatis([[Target: x86_64]])
whatis([[Short description :  This is a redundant module to load the base micromamba environment as an example.]])

family("mm_env")

-- Modify String In Quotes To Match Desired Environment Name or Path
local env_name = "base"
-- Don't forget to update line 2/3 aswell to update the Module Name/Version

execute{cmd="micromamba activate " .. env_name,modeA={"load"}}
execute{cmd="micromamba deactivate",modeA={"unload"}}

The above output shows that base.lua is in /home/tahat/sstack/stacks/micromamba/20222A/modules. You need to create a module file my_env.lua in the same path, as follows:

touch /home/tahat/sstack/stacks/micromamba/20222A/modules/my_env.lua

Now, you need to copy the content of the base.lua file into my_env.lua.

cp /home/tahat/sstack/stacks/micromamba/20222A/modules/base.lua /home/tahat/sstack/stacks/micromamba/20222A/modules/my_env.lua

Now you need to update my_env.lua to have the correct environment name env_name as commented in line 9 in the file.

vim /home/tahat/sstack/stacks/micromamba/20222A/modules/my_env.lua

Update line 2 and 10, with the correct env-name.

------------------------------------------------------------------------------------------------------------------------------------------------------------
help([[For help contact hpc-team@nmsu.edu]])
whatis([[Name : Micromamba my_env Env]])
whatis([[Version: Latest]])
whatis([[Target: x86_64]])
whatis([[Short description :  This is a redundant module to load the base micromamba environment as an example.]])

family("mm_env")

-- Modify String In Quotes To Match Desired Environment Name or Path
local env_name = "my_env"
-- Don't forget to update line 2/3 aswell to update the Module Name/Version

execute{cmd="micromamba activate " .. env_name,modeA={"load"}}
execute{cmd="micromamba deactivate",modeA={"unload"}}

Check if the created module is available:

module avail my_env

Output

-------------------------------------------------------- /home/tahat/sstack/stacks/micromamba/20222A/modules ---------------------------------------------------------
   my_env

Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".

For more information visit micromamba documentation