Difference between revisions of "Conda"

From UFRC
Jump to navigation Jump to search
(Created page with "Category:Software {|<!--CONFIGURATION: REQUIRED--> |{{#vardefine:app|conda}} |{{#vardefine:url|https://docs.conda.io/en/latest/miniconda.html}} <!--CONFIGURATION: OPTIONAL...")
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Software]]
+
[[Category:Software]][[Category:Programming]]
 
{|<!--CONFIGURATION: REQUIRED-->
 
{|<!--CONFIGURATION: REQUIRED-->
 
|{{#vardefine:app|conda}}
 
|{{#vardefine:app|conda}}
 
|{{#vardefine:url|https://docs.conda.io/en/latest/miniconda.html}}
 
|{{#vardefine:url|https://docs.conda.io/en/latest/miniconda.html}}
 
<!--CONFIGURATION: OPTIONAL (|1}} means it's ON)-->
 
<!--CONFIGURATION: OPTIONAL (|1}} means it's ON)-->
|{{#vardefine:conf|}}          <!--CONFIGURATION-->
+
|{{#vardefine:conf|1}}          <!--CONFIGURATION-->
 
|{{#vardefine:exe|1}}            <!--ADDITIONAL INFO-->
 
|{{#vardefine:exe|1}}            <!--ADDITIONAL INFO-->
 
|{{#vardefine:job|}}            <!--JOB SCRIPTS-->
 
|{{#vardefine:job|}}            <!--JOB SCRIPTS-->
Line 13: Line 13:
 
|{{#vardefine:installation|}} <!--INSTALLATION-->
 
|{{#vardefine:installation|}} <!--INSTALLATION-->
 
|}
 
|}
 +
 +
See also: [https://help.rc.ufl.edu/doc/Managing_Python_environments_and_Jupyter_kernels Managing Python environments and Jupyter kernels]
 
<!--BODY-->
 
<!--BODY-->
 
<!--Description-->
 
<!--Description-->
Line 18: Line 20:
 
{{App_Description|app={{#var:app}}|url={{#var:url}}|name={{#var:app}}}}|}}
 
{{App_Description|app={{#var:app}}|url={{#var:url}}|name={{#var:app}}}}|}}
  
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.  
+
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.
  
Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. Use the conda install command to install additional conda packages from repositories (channels) like [https://bioconda.github.io/ bioconda].
+
'''Note:''' For a ''faster conda'' see [[Mamba]].
  
 
<!--Modules-->
 
<!--Modules-->
Line 27: Line 29:
 
==System Variables==
 
==System Variables==
 
* HPC_{{uc:{{#var:app}}}}_DIR - installation directory
 
* HPC_{{uc:{{#var:app}}}}_DIR - installation directory
 +
* HPC_{{uc:{{#var:app}}}}_BIN - executable directory
 
<!--Configuration-->
 
<!--Configuration-->
 
{{#if: {{#var: conf}}|==Configuration==
 
{{#if: {{#var: conf}}|==Configuration==
See the [[{{PAGENAME}}_Configuration]] page for {{#var: app}} configuration details.
+
<!-- See the [[{{PAGENAME}}_Configuration]] page for {{#var: app}} configuration details. -->
 +
'''Note:''' If you are an active conda user conda package cache can quickly fill up your home directory. We recommend changing the <code>pkgs_dirs</code> 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.
 +
<pre>
 +
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
 +
</pre>
 
|}}
 
|}}
 
<!--Run-->
 
<!--Run-->
Line 35: Line 57:
 
UF Research Computing Applications Team uses conda for many application installs behind the scenes. We are happy to [https://support.rc.ufl.edu 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.
 
UF Research Computing Applications Team uses conda for many application installs behind the scenes. We are happy to [https://support.rc.ufl.edu 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 would like to point out that there is a clear distinction between using conda environments to install packages and using applications installed in those environments. To use a conda environment you need to add its 'bin' directory to your shell $PATH whether in an interactive session or a job script submitted to the scheduler. To modify a conda environment by installing or removing packages you need to 'activate' the environment. Because of that distinction we strongly recommend against allowing miniconda 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  
+
* We suggest not installing your own copy of miniconda or anaconda, but using one of our conda or [[Mamba|mamba]] environment modules (<code>module load conda</code>) 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 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
 +
conda create -yp /path/to/the/environment
 +
command instead of 'conda create -n name_of_the_env'
 +
 
 +
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  
 
<pre>
 
<pre>
 
# >>> conda initialize >>>
 
# >>> conda initialize >>>
Line 44: Line 80:
 
lines.
 
lines.
  
Instead, load our conda environment module, which we keep up-to-date with conda releases any time you need to create conda environments and to install packages in them. The difference is that 'conda activate' command will not be available, so you will have to use 'source activate' command instead.  
+
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.
 
E.g.
  
 
  $ module load conda
 
  $ module load conda
  $ source activate /a/path/to/an/environment/i/created
+
  $ conda activate /path/to/the/environment
  
 
Once you are done installing packages inside the environment you can use
 
Once you are done installing packages inside the environment you can use
Line 92: Line 128:
 
See the [[{{PAGENAME}}_Install]] page for {{#var: app}} installation notes.|}}
 
See the [[{{PAGENAME}}_Install]] page for {{#var: app}} installation notes.|}}
 
<!--Turn the Table of Contents and Edit paragraph links ON/OFF-->
 
<!--Turn the Table of Contents and Edit paragraph links ON/OFF-->
__NOTOC____NOEDITSECTION__
+
__NOEDITSECTION__

Revision as of 18:23, 12 October 2022

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

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

command instead of 'conda create -n name_of_the_env'

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

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

lines.

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