Using conda at Cerfacs

By Victor Xing - 2020/06/15


What is conda?

conda is a language-agnostic package and environment manager. For Python, it can replace the combined use of pip and venv. Using virtual environments is heavily encouraged at Cerfacs because they offer project-specific, user-controlled, clean work environments. For the most part, conda and pip+venv are interchangeable and choosing one or the other comes down to user preference. I personally like the flexibility of conda and its ability to easily control the Python version of virtual environments.

There are many conda tutorials out there. This post will focus on how to use it on the Kraken and Nemo internal clusters at Cerfacs.

Setting up conda on the internal clusters

At the time of writing, conda versions 4.4.10 and 4.5.1 are installed on Kraken and Nemo, respectively.

module load python3.6/anaconda

This will enable all conda commands and activate a default base environment containing a few basic packages.

An important caveat is that by default, conda stores its cache (containing package builds that can be reused for later installs) and environments in the home directory. Since the home directory of the clusters has limited disk and inode space, you should specify a better-suited location, for instance a dedicated pyenvs directory in the scratch. Create a ~/.condarc file and add in the following lines:

envs_dirs:
    - /scratch/coop/<yourusername>/pyenvs
pkgs_dirs:
    - /scratch/coop/<yourusername>/pyenvs/conda-pkgs
conda create --name=toto python=3.7 tensorflow=2.1.0

This will create a /scratch/coop/<yourusername>/pyenvs/toto directory with your new environment. To create an environment at a different location from the one specified in envs_dirs, go to that directory and use --prefix instead of --name.

When creating the environment, you should specify all the packages you know will be included so that dependencies can be handled in the best possible way.

conda activate toto
conda install numpy=1.19

Notes

python -m ipykernel install --user

A detailed write-up on conda

Conda command cheatsheet