Conda#
Conda is a free software package and environment manager used primarily for scientific Python and R packages, but also supports other languages such as C, C++, FORTRAN, Java, Scale, Ruby and Lua.
Use Conda in TeideHPC#
Once we have connected to the login nodes, we will have to load the miniconda
module to start using conda:
Once the software is loaded, we can, for example, see the version information of conda:
conda info
active environment : None
user config file : /home/vjuidias/.condarc
populated config files : /home/vjuidias/.condarc
conda version : 4.7.10
conda-build version : not installed
python version : 2.7.16.final.0
virtual packages :
base environment : /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10 (read only)
channel URLs : https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
https://conda.anaconda.org/bioconda/linux-64
https://conda.anaconda.org/bioconda/noarch
https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
https://conda.anaconda.org/r/linux-64
https://conda.anaconda.org/r/noarch
package cache : /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/pkgs
/home/vjuidias/.conda/pkgs
envs directories : /home/vjuidias/.conda/envs
/opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/envs
platform : linux-64
user-agent : conda/4.7.10 requests/2.22.0 CPython/2.7.16 Linux/3.10.0-327.el7.x86_64 centos/7.2.1511 glibc/2.17
UID:GID : 1136:1136
netrc file : None
offline mode : False
Now we have to initialise the shell to use Conda. This step is only necessary the first time. If we don't do it, when using conda, we will get this message:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
So, what we have to do is:
conda init bash
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/condabin/conda
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/bin/conda
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/bin/conda-env
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/bin/activate
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/bin/deactivate
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/etc/profile.d/conda.sh
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/etc/fish/conf.d/conda.fish
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/shell/condabin/Conda.psm1
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/shell/condabin/conda-hook.ps1
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/lib/python2.7/site-packages/xontrib/conda.xsh
no change /opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/etc/profile.d/conda.csh
modified /home/vjuidias/.bashrc
==> For changes to take effect, close and re-open your current shell. <==
By doing this, we have modified the shell, in this case, our bash. We have added the following lines to the file ~/.bashrc
:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/etc/profile.d/conda.sh" ]; then
. "/opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/etc/profile.d/conda.sh"
else
export PATH="/opt/envhpc/slurm19/rhel7/Miniconda2/4.7.10/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
For the changes to take effect, we have to log out of the login node and log back in. Once this is done, we will be able to use conda, install packages and create environments.
Create an environment in /data#
By default, Conda will create an environment and install all software on the user's /home
partition. This storage is limited in size, so we should configure the environments and install the software in the /data
partition. To do this, we simply need to specify the path to Conda:
conda create -p data/myenvironment mysoftware
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /data/vjuidias/myenvironment
...
And we activate it in the same way, specifying the route: