Anaconda

  • load Anaconda module
module load Anaconda3/2021.11˛
  • create new environment named myenvironment for python 3.9.7 for example
conda create --quiet --yes --name myenvironment --python=3.9.7
  • activate environment
conda activate myenvironment
  • check the environment
conda env list
  • install packages
conda install --quite --yes pyyaml ipython scikit-learn tqdm
  • remove environment (if you don't need it anymore)
conda env remove -n myenvironment

In your job, just specify the env that you want to use:

#!/bin/bash
#SBATCH -n 2
#SBATCH -N 2
#SBATCH -p cpu
#SBATCH --mem=XY

module load Anaconda3/2021.11

source activate myenvironment

python3 myjob.py
  • change environment location in condarc
$ cat ~/.condarc
channels:
  - defaults
ssl_verify: true
envs_dirs:
  - /ceph/hpc/home/myusername/anaconda_envs
pkgs_dirs:
  - /ceph/hpc/home/myusername/anaconda_envs