Using Conda on the ScienceCluster¶
Conda-based environment management on ScienceCluster is provided through the miniforge3 module. To enable conda (and mamba) in your session, load the module with:
module load miniforge3
Miniforge3 includes access to both conda and the faster drop-in replacement mamba, which offers significantly faster performance, especially when resolving complex dependency trees.
Info
Please refer to the generic guide Using Conda for instructions about using Conda environments.
Verify your .condarc file¶
To check your current .condarc settings:
cat ~/.condarc
If you need to reset or create a new .condarc file with the default settings run:
cat << EOF > ~/.condarc
channels:
- conda-forge
envs_dirs:
- ~/conda/envs
pkgs_dirs:
- ~/conda/pkgs
auto_activate_base: false
channel_priority: strict
EOF
Workflow Overview¶
On ScienceCluster, we recommend the following workflow for integrating a Conda environment into your submission scripts:
-
Set Up Your Environment: To install the required packages, first start an interactive session. Then, create your Conda environment and install the necessary packages within that session.
-
Integrate Environment into SLURM Script: After installing the packages, exit the interactive session. On the login nodes, integrate the Conda environment into your SLURM script and submit the batch script from the login node.
Create your environment on ScienceCluster¶
To create a Conda environment, it’s best to work within an interactive session on a compute node. Doing so allows you to access greater resources than the login nodes:
srun --pty -n 1 -c 4 --time=01:00:00 --mem=16G bash -l
module load miniforge3
mamba create --name myenv python=3.14
Tip
If your environment will install GPU-accelerated packages, request a GPU compute node by adding --gpus=1 to your srun command. See our guide for more information and examples.
To activate the environment:
source activate myenv
Tip
On the ScienceCluster, you can ignore Conda's instruction to use conda activate. Use source activate instead.
After activation your shell prompt will show the environment name:
(myenv) <username>@<hostname>
With your environment active you’re ready to install packages, run your applications, or begin your analysis.
Submitting a sbatch job with a Conda environment¶
Below is an example sbatch script for submitting a non-interactive job using an existing Conda environment:
#!/usr/bin/bash -l
#SBATCH --time=0-00:10:00 # runtime limit (D-HH:MM:SS), here 10 minutes
#SBATCH --mem=4G # memory per node
#SBATCH --ntasks=1 # number of tasks (usually 1 for most jobs)
#SBATCH --cpus-per-task=1 # number of CPUs per task
module load miniforge3
source activate myenv
python3 /home/$USER/mycode.py