Skip Navigation

Mamba

Skip Side Navigation

!!! CAUTION !!! Please do NOT run python command directly in the SSH terminal!

By doing so, you are running a potentionally intensive computing task on OSCER login machines. Intensive computing tasks had a tendency to crash the login machines, thus preventing all other 1000+ OSCER users from logging in! Please make sure to read the Python Basic Setup instruction to understand how to properly set up a Python environment and submit a Python batch job on the supercomputer.

If you have trouble following the instruction below, feel free to join OSCER weekly zoom help sessions,

!!! CAUTION !!! Please do NOT create Python environments in /OURdisk partitions

We have been advised that using Conda, Mamba, or standard virtual environments on Ceph storage systems like OURdisk poses a high risk to the entire storage infrastructure. To avoid issues, please install all software within your home directory following the instructions provided below. If you reach your home directory quota, contact support at support.oscer.ou.edu for assistance.

Mamba (Conda) Setup

Many Python projects, especially those involving machine learning, deep learning, or data analytics, use Conda for managing environments and dependencies. However, Conda can be slow and use several gigabytes of storage. When possible, we recommend following the Python Basic Setup guide and using standard Python environments.

If your project is too complicated to setup with a standard Python environment from scratch and you feel like you must use Conda, we recommend Mamba. This is a faster drop-in replacement that significantly reduces environment-creation time.

Below are the steps to use Mamba on OSCER systems.

  1. Loading the Mamba Module  
  2. Creating a Mamba environment and Installing Packages
  3. Using a Mamba Environment in a Batch Job

For additional quick-reference commands, see our Mamba Cheat Sheet.

1. Loading the Mamba Module

To load the Mamba module, type:

module load Mamba

OSCER currently provides: Mamba/25.9.1.0 on Sooner and Mamba/23.1.0.4 on Schooner

We recommend not running mamba init as it adds configuration lines to your  ~/.bashrc that can interfere with other Anaconda-based environments. 

If your terminal prompt shows (base), it means you previously ran mamba init or conda init. To unitialize it:

  1. Open ~/.bashrc                            
  2. Comment out or delete the entire conda/mamba block at the end of the file (including any activate lines)
  3. Log out and log back in

Instead of using mamba init, you will activate environments manually using source activate.

2. Creating a New Mamba Environment and Installing Packages

The next step is to create a Mamba environment tailored to the requirements of your Python code or GitHub project. In this example, we use the PICRUSt2 GitHub project. According to the official PICRUSt2 installation guide, you can set up the environment with the following command: 

mamba create -n picrust2 -c bioconda -c conda-forge picrust2

This command creates a mamba environment named picrust2 and installs the PICRUSt2 package along with all required dependencies from the bioconda and conda-forge channels. In our testing, mamba completed dependency resolution and installation in about five minutes. Running the same command with conda instead can take hours, sometimes even days.

Activate the environment by typing:

source activate picrust2

Your prompt should now begin with:

(picrust2)

To install packages from a Mamba/Conda channel, type:

mamba install -c conda-forge <package>

To install a package through pip, type:

pip install <package>

 

IMPORTANT: Before installing anything with mamba install or pip install, always activate the environment first:

source activate <environment>

3. Using a Mamba Environment in a Batch Job

Inside your batch script, load Mamba and activate your environment:

module load Mamba

source activate picrust2


Below is an example test_mamba.sbatch script that runs a simple test_picrust2.py job on the debug partition, requesting 1 CPU, 1 GB of memory, and 10 minutes of run time:

#!/bin/bash
#
#SBATCH --partition=debug
#SBATCH --output=mamba_%J_stdout.txt
#SBATCH --error=mamba_%J_stderr.txt
#SBATCH --chdir=/path/to/your/working/directory
#SBATCH --ntasks=1
#SBATCH --mem=1G
#SBATCH --time=00:10:00

module load Mamba

source activate picrust2

python test_picrust2.py

Replace /path/to/your/working/directory with the full absolute path to where you want your Python script to run.

Once updated, submit the batch script by typing: After that, submit your batch script by typing:

sbatch test_mamba.sbatch

 

Mamba Cheat Sheet

  • We recommend creating a new environment for each project or workflow.
  • Mamba automatically resolves package dependencies and platform-specific requirements.
  • You must load the Mamba module first (module load Mamba) to use any of the commands below.
  • See the Mamba documentation for additional Mamba commands and options.

 

Command Description
mamba create -n ENVNAME Create a new environment named ENVNAME (choose a descriptive name)
source activate ENVNAME Activate the environment ENVNAME
source deactivate Deactivate the current environment
mamba env list List all environments and their locations
mamba list -n ENVNAME --show-channel-urls List all packages in ENVNAME along with their source channels 
mamba install -n <env_name> pkg1 pkg2 Install packages pkg1 and pkg2 into ENVNAME
mamba uninstall pkg1 -n ENVNAME Remove package pgk1 from ENVNAME
mamba update --all -n ENVNAME Update all packages in ENVNAME
mamba remove -n ENVNAME --all Eelete the environment ENVNAME entirely
mamba env export --format explicit ENVNAME > ENVNAME.yml  Export the environment to an explicit ENVNAME.yml file
mamba env create -n ENVNAME --file ENVNAME.yml Create the environment ENVNAME from the ENVNAME.yml file
mamba create --name ENVNAME --clone /path/to/mamba/env/on/ourdisk Since Mamba environments are not allowed on /ourdisk, clone the environment into your home directory using this command