Conda

From UFRC
Revision as of 15:40, 13 January 2023 by Israel.herrera (talk | contribs)
Jump to navigation Jump to search

See also: Managing Python environments and Jupyter kernels

Description

conda website  

Conda is an open-source package management system and environment management system that runs on Windows, macOS, and Linux. Conda quickly installs, runs, and updates packages and their dependencies. Conda easily creates, saves, loads, and switches between environments. Separating applications in separate conda environments allows installation of incompatible dependencies - python2 and python3 for example.

Note: For a faster conda see Mamba.

Environment Modules

Run module spider conda to find out what environment modules are available for this application.

System Variables

  • HPC_CONDA_DIR - installation directory
  • HPC_CONDA_BIN - executable directory

Configuration

Note: If you are an active conda user conda package cache can quickly fill up your home directory. We recommend changing the pkgs_dirs setting in ~/.condarc to point to another filesystem e.g.

pkgs_dirs:
   - /blue/gators/albert/conda/pkgs

Here is an example ~/.condarc. Change 'GROUP' and USER to the name of your group and username or type the exact path.

channels:
  - conda-forge
  - bioconda
  - defaults
envs_dirs:
  - /blue/GROUP/USER/conda/envs
pkgs_dirs:
  - /blue/GROUP/USER/conda/pkgs
auto_activate_base: false
auto_update_conda: false
always_yes: false
show_channel_urls: false

Additional Information

UF Research Computing Applications Team uses conda for many application installs behind the scenes. We are happy to install applications on request for you. However, if you would like to use conda to create multiple environments for your personal projects we encourage you to do so. Here are some recommendations for successful conda use on HiPerGator.

  • We suggest not installing your own copy of miniconda or anaconda, but using one of our conda or mamba environment modules (module load conda) to get the 'conda engine' for free. A personal miniconda3 install will overwrite your ~/.bashrc into your ~/.conda/envs directory, which could fill up your home_quota very fast.

See https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html for the original documentation on managing conda environments.

We recommend using '-p' argument to create environments by 'path', so they wouldn't fill up your home directory (check quota with home_quota). The resulting environment should be located in the project(s) directory tree in /blue for better tracking of installs and better filesystem performance compared to home.

Use the following command instead of 'conda create -n name_of_the_env'

conda create -yp /path/to/the/environment

There is a clear distinction between creating or modifying conda environments and using applications installed in those environments. To use applications installed in a conda environment in most cases you only need to add its 'bin' directory to the $PATH whether in an interactive session or a job script submitted to the scheduler. In rare cases LD_LIBRARY_PATH variable also needs to be set to the 'lib' sub-directory of the conda environment.

To modify a conda environment by installing or removing packages you need to 'activate' the environment first with a 'conda activate /path/to/the/conda/env' command.

Because of that distinction we strongly recommend against installing miniconda manually and allowing it to insert its activation code into your shell initialization file ~/.bashrc. If you already let it do so please remove the offending code from ~/.bashrc. It's the text within and including the following lines:

# >>> conda initialize >>>
...
# <<< conda initialize <<<

Instead, load the conda environment module with 'module load conda' when needed to create or modify conda environments, but only set PATH when using the environment as shown above.

E.g.

$ module load conda
$ conda activate /path/to/the/environment

Once you are done installing packages inside the environment you can use

$ conda deactivate

We do not recommend activating conda environments when _using_ them i.e. running programs installed in the environments. Please prepend the path to that environment to your $PATH instead.

E.g. If you have a project-specific conda environment at '/home/myuser/envs/project1/' add the following into your job script before executing any commands

export PATH=/home/myuser/envs/project1/bin:$PATH