Module Miniforge3
Read the documentation to manage conda environments.
Create a conda environment
Open an interactive session to a compute node. Adjust the number of CPUs (--cpus-per-task 1) and the amount of memory (--mem 4G) needed for your job. Increase the number of --cpus-per-task only when using code that can run in parallel.
srun --cpus-per-task 1 --mem 4G --pty bash
Load miniforge3 module.
module load miniforge3/23.3.1
Create a conda environment with a specific name (e.g. myenv) and a specific version of Python (e.g. 3.11).
conda create -n myenv python=3.11
Activate the conda environment.
conda activate myenv
Install any packages in the conda environment (e.g. numpy and pandas). You can use pip as long as `which pip` points to your conda environment (as in ~/.conda/envs/myenv/bin/pip). It is recommended not to install pip packages outside of specific conda environments.
conda install numpy pandas
or
pip install numpy pandasDeactivate the conda environment when no longer needed.
conda deactivate
Using an existing shared conda environment
A selection of commonly used conda environments is available to everyone. Run the following command to list the existing environments:
conda info --envs
This list includes:
pytorch-2.1.2_cuda-12
Activate the environment. Some environments (named with cuda) need to be run on a GPU node.
conda activate pytorch-2.1.2_cuda-12
Using conda in a batch job
To load miniforge3 and activate the conda environment include the module load and conda activate lines after the #SBATCH job descriptors and before calling the Python code.
#!/bin/bash
#SBATCH ...
module load miniforge3/23.3.1
conda activate myenv
python ...