Managing Conda Environments on the HPC
SOP ID: HPC-002 Version: 1.0 Date: 2026-02-23 Author: AGRP
Overview
Conda is a package and environment manager that lets you install bioinformatics software without needing administrator access. Each environment is an isolated space with its own set of tools and versions — so different projects never conflict with each other.
Full Course Available
This SOP covers the essentials. For a comprehensive walkthrough including advanced workflows and best practices, see the full course:
1. Installation
Each user installs conda in their own home directory. Download and run the Miniconda installer:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
Accept the defaults and allow the installer to initialise conda in your .bashrc. Then reload your shell:
Confirm it works:
2. First-Time Setup
Add the bioinformatics channels so that tools like GATK, BWA, and QIIME2 are available:
conda config --add channels defaults
conda config --add channels bioconda
conda config --add channels conda-forge
3. Creating an Environment
Always create a dedicated environment for each project or tool rather than installing everything into base.
Activate it:
Your prompt will update to show the active environment:
4. Installing Software
With your environment active, install tools using conda install:
Search for a package:
5. Essential Commands
| Command | What it does |
|---|---|
conda activate my_env |
Switch into an environment |
conda deactivate |
Return to base |
conda env list |
List all your environments |
conda list |
List packages in the active environment |
conda install package |
Install a package |
conda remove package |
Remove a package |
conda env remove -n my_env |
Delete an environment entirely |
6. Sharing and Reproducing Environments
Export your environment so collaborators (or your future self) can recreate it exactly:
Recreate it from the file:
7. Using Conda in SLURM Jobs
Activate your environment inside your SLURM batch script:
#!/bin/bash
#SBATCH --job-name=my_analysis
#SBATCH --partition=agrp
#SBATCH --cpus-per-task=4
#SBATCH --mem=8G
source ~/miniconda3/etc/profile.d/conda.sh
conda activate my_project
# Your commands here
python my_script.py
Warning
Do not rely on your .bashrc to activate conda inside batch jobs — always source it explicitly as shown above.
Further Reading
- Full Conda for Bioinformatics Course — covers advanced workflows, Snakemake/Nextflow integration, and best practices
- Official Conda documentation
- Bioconda package list