Miniforge3
Preferred Alternatives
- If you want a more reproducible and isolated environment, we recommend using the Apptainer containers.
- If you only need access to Python and standard numerical libraries (numpy, scipy, matplotlib, etc.), you can use the Python environment module.
Community-led recipes, infrastructure and distributions for conda. Miniforge3 Homepage
Available Modules¶
module load Miniforge3/25.3.1-0
The Miniforge3 environment module provides the
Conda package and
environment manager. Conda lets you install packages and their
dependencies in dedicated environment, giving you more freedom to
install software yourself at the expense of possibly less optimized
packages and no curation by the NeSI team.
Module loading and conda environments isolation¶
When using the Miniforge3 module, we recommend using the following snippet to ensure that your conda environments can be activated and are isolated as possible from the rest of the system:
module purge && module load Miniforge3
source $(conda info --base)/etc/profile.d/conda.sh
export PYTHONNOUSERSITE=1
Here are the explanations for each line of this snippet:
module purge && module load Miniforge3ensures that no other environment module can affect your conda environments. In particular, the Python environment module change thePYTHONPATHvariable, breaking the isolation of the conda environments. If you need other environment modules, make sure to load them after this line.source $(conda info --base)/etc/profile.d/conda.shensures that you can use theconda activatecommand.export PYTHONNOUSERSITE=1makes sure that local packages installed in your home folder~/.local/lib/pythonX.Y/site-packages/(whereX.Yis the Python version, e.g. 3.8) bypip install --userare excluded from your conda environments.
Warning
We strongly recommend against using conda init. It inserts a
snippet in your ~/.bashrc file that will freeze the version of conda
used, bypassing the environment module system.
Defaults Channel
If you are using a environment.yml file, you will have to remove the
defaults channel, or you will receive an error.
Failed to create Conda environment
The channel is not accessible or is invalid.
The defaults channel is blocked due to Anaconda's licensing requirements.
Prevent conda from using /home storage¶
Conda environments and the conda packages cache can take a lot of storage space. By default, Conda use /home, which is restricted to 20GB on NeSI. Here are some techniques to avoid running out of space when using Conda.
First, we recommend that you move the cache folder used for downloaded
packages on the nobackup folder of your project:
conda config --add pkgs_dirs /nesi/nobackup/<project_code>/$USER/conda_pkgs
where <project_code> should be replace with your project code. This
setting is saved in your ~/.condarc configuration file.
Prerequisite
Your package cache will be subject to the nobackup autodelete process (details available in the Nobackup autodelete support page). The package cache folder is for temporary storage so it is safe if files within the cache folder are removed.
Next, we recommend using the -p or --prefix options when creating
new conda environments, instead of -n or --name options. Using -p
or --prefix, you can specify the conda environment folder location,
ideally in your project folder. For example:
conda create --prefix /nesi/project/<project_code>/my_conda_env python=3.8
Then use the path of the conda environment to activate it:
conda activate /nesi/project/<project_code>/my_conda_env
Note that -p and --prefix options can also be used when creating an
environment from an environment.yml file:
conda env create -f environment.yml -p /nesi/project/<project_code>/my_conda_env
Reduce prompt prefix
By default, when activating a conda environment created with -p or
--prefix, the entire path of the environment is be added to the
prompt. To remove this long prefix in your shell prompt, use the
following configuration:
conda config --set env_prompt '({name})'