Skip to content

How to Speed Up Conda Environment Creation and Package Installation: 10x Faster with Mamba

How to Speed Up Conda Environment Creation and Package Installation: 10x Faster with Mamba

Conda environment creation takes forever. The “solving environment” step drags on for 10-30 minutes when installing complex Python packages. This frustration drives many developers away from Conda entirely.

The root cause is Conda’s SAT solver algorithm. Switching to Mamba with libmamba solver cuts environment creation times from minutes to seconds while maintaining full compatibility with Conda’s CLI.

The Problem: SAT Solver Bottleneck

Conda uses a SAT (Boolean Satisfiability) solver to resolve package dependencies. This algorithm has exponential complexity that becomes painfully slow with complex dependency trees.

Scientific Python stacks with packages like numpy, pandas, scipy, matplotlib, tensorflow, and pytorch create intricate dependency graphs. The SAT solver struggles with these complex relationships, taking 15-30 minutes to resolve dependencies.

This slow resolution frustrates users and discourages proper environment management. Many developers abandon Conda entirely for faster alternatives like pip.

The Solution: Libmamba Dependency Graph Algorithm

Mamba replaces the SAT solver with libmamba, which uses a dependency graph algorithm with linear complexity. This approach handles complex package trees efficiently while maintaining all Conda functionality.

You have two options:

Option 1: Use Mamba Directly (Maximum Speed)

Terminal window
# Install mamba
conda install -n base -c conda-forge mamba
# Create environments 10x faster
mamba create -n myenv python=3.10 numpy pandas scipy matplotlib
mamba activate myenv
# Install packages in seconds
mamba install -c conda-forge tensorflow pytorch jupyterlab

Option 2: Configure Conda with Libmamba Solver (Familiar CLI)

Terminal window
# Configure conda to use libmamba solver
conda config --set solver libmamba
# Now all conda commands use the fast solver
conda create -n myenv python=3.10
conda install tensorflow pytorch

Performance Benchmark Comparison

Here’s a benchmark script to test the performance difference:

#!/bin/bash
# Benchmark script to compare conda vs mamba performance
echo "Testing standard Conda..."
time conda create -n conda-test python=3.10 numpy pandas scipy -y
rm -rf conda-test
echo "Testing Mamba..."
time mamba create -n mamba-test python=3.10 numpy pandas scipy -y
rm -rf mamba-test
echo "Testing libmamba solver with conda..."
conda config --set solver libmamba
time conda create -n libmamba-test python=3.10 numpy pandas scipy -y
rm -rf libmamba-test

Typical results:

  • Conda: 45-120 seconds
  • Mamba: 3-8 seconds
  • Libmamba solver with conda: 5-12 seconds

Complete Workflow Example

Here’s how to set up your data science environment with maximum performance:

Terminal window
# 1. Install and configure mamba
conda install mamba -n base
conda config --set solver libmamba
# 2. Create environment with specific packages
conda create -n datascience python=3.10 -y
conda activate datascience
# 3. Install packages with automatic solver selection
conda install -c conda-forge pandas numpy matplotlib scikit-learn tensorflow -y
# 4. Alternative: use mamba directly for critical packages
mamba install -c conda-forge pytorch jupyterlab plotly -y
# 5. Export environment
conda env export > datascience.yml

Why This Matters

Faster dependency resolution impacts your entire development workflow:

  • Faster iteration cycles - Spend coding instead of waiting for installations
  • Better user experience - Proper environment management becomes feasible
  • CI/CD optimization - Critical for pipelines where time equals cost
  • Reduced context switching - Fewer workflow interruptions

Common Mistakes to Avoid

  1. Not realizing you can use Mamba while keeping Conda’s familiar CLI

    • Many developers don’t know about the libmamba solver configuration option
  2. Overlooking the importance of specifying the libmamba solver explicitly

    • Default settings keep the slow SAT solver
  3. Not updating all conda-related commands to use the faster solver

    • Some commands might still use the old solver if not configured properly
  4. Ignoring channel configuration which affects performance

    • Proper channel setup ensures optimal package resolution

SAT Solver vs Dependency Graph Algorithm

The fundamental difference between Conda and Mamba lies in their dependency resolution algorithms:

  • SAT Solver (Conda): Boolean satisfiability problem with exponential complexity

    • Tests all possible combinations of package versions
    • Becomes extremely slow with many dependencies
    • Guarantees optimal solution but at high computational cost
  • Dependency Graph Algorithm (Mamba): Linear complexity approach

    • Directly traverses dependency relationships
    • Much faster for complex package trees
    • Maintains compatibility while dramatically improving performance

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments