Anaconda Usage
Overview
Anaconda is a free and open source Python and R distribution, which includes binaries such as, Scipy, Numpy, Pandas along with all their dependencies.
Conda is an open source package management system and environment management system. Conda is designed to manage packages and dependencies within any software stack, more like yum and apt, conda is a language-agnostic cross-platform environment manager.
In order to accomodate Nero Users to install and customize their SW environments, we have set up a local mirror of Anaconda distributions.
The following is a list of default channels included in our anaconda distribution.
Base Conda Channels Mirrors
Channel | Channel Map |
---|---|
main | https://nero-mirror.stanford.edu/conda/main |
conda-forge | https://nero-mirror.stanford.edu/conda/conda-forge |
Other Available Conda Channel Mirrors
bioconda | https://nero-mirror.stanford.edu/conda/bioconda |
free | https://nero-mirror.stanford.edu/conda/free |
hcc | https://nero-mirror.stanford.edu/conda/hcc |
pytorch | https://nero-mirror.stanford.edu/conda/pytorch |
soumith | https://nero-mirror.stanford.edu/conda/soumith |
To use Anaconda 3
Connect to Stanford VPN
Login to nero.compute.stanford.edu
ssh $username@nero.compute.stanford.edu
Source Anaconda 3 with module load
module load anaconda
Search for desired software packages from base channels
Check current loaded version of package
conda list -f $PACKAGENAME
Check versions available from the conda mirror with:
conda search -f $PACKAGENAME
conda search -f boto3
Check for certain version
conda search -f boto3=1.9.21
Search for desired software packages from specific channel
conda search -f $PACKAGENAME -c <channel>
conda search -f samtools -c https://nero-mirror.stanford.edu/conda/bioconda
Create and use custom environment using base channels
A conda custom environment is a directory that contains a specific collection of conda packages that you want installed.
conda create -p <path to directory> <sw> <sw>
conda create -p /home/$USER/envs/dev numpy scipy
To specify version
conda create -p <path to directory> <sw>=<version>
conda create -p /home/$USER/envs/python_2.7 python=2.7
To utilize an environment
conda activate /home/$USER/envs/python_2.7
To deactivate current environment
conda deactivate
Create custom environment using non-base channel
conda create -p /home/$USER/envs/bio-env -c <channel to use> <sw>=<version>
example
conda create -p /home/$USER/envs/bio-env -c https://nero-mirror.stanford.edu/conda/bioconda bwa=0.7.15 samtools=1.3.1
Activate and deactivate as done above
conda activate /home/$USER/envs/bio-env
Add packages to custom environment
conda activate /home/$USER/envs/python_2.7
conda install <packagename>
conda install curl
If non-base channel is needed you will need to specifiy the channel
conda activate /home/$USER/envs/bio-env
conda install bcftools -c https://nero-mirror.stanford.edu/conda/bioconda
Using pip with your custom environment
If conda does not have the package you may need to use Pip:
conda activate /home/$USER/envs/env-name
pip install --user packagename
If pip fails, make sure you have a “.pip/pip.conf” file in your home directory, with the following contents:
[global]
index-url = https://nero-mirror.stanford.edu/pypi/simple
Export environment to a file
conda actvate /home/$USER/envs/bio-env
conda env export > bio-environment.yaml
Which can then be used by someone else to create same environment
conda create -p /home/$USER/envs/bio-env --file bio-environment.yaml
Managing Quota Space Used by Anaconda
Anaconda has a tendency to use disk space - especially the package cache. You can alleviate the usage of your home directory quota (10GB) by setting your “.condarc” and specifying a envs_dir location with the following command. We suggest setting it to your “/share/pi/” directory as there is more quota available there.
conda config --add envs_dirs <path to directory>