6. Anaconda
6.1. One Time Setup
Conda is already available on Greene. To access the default conda environment, just type the following.
module load anaconda3/2020.07
There’s a caveat though, when you try to create a new virtual environment, it does that in the /home
directory by default, and that takes up a lot of space out of your quota. As a workaround, direct conda to store packages data at /scratch
.
conda config --append pkgs_dirs /scratch/$USER/conda/pkgs_dirs
conda config --append envs_dirs /scratch/$USER/conda/envs_dirs
Common Error
Sometimes, conda might throw an error:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'
.
To resolve this, you might want to run
conda init bash
6.2. Create environment
You need to make conda accessible from you shell by running the followind command:
module load anaconda3/2020.07
eval "$(conda shell.bash hook)"
You can now proceed to create a new virtual environment
conda create -n <env_name> python=3.8
6.3. Activate conda
Load anaconda module to make conda accessible from you shell by running the followind command:
module load anaconda3/2020.07
eval "$(conda shell.bash hook)"
Activate an existing environment
conda activate <env_name>
Recommended
The number of files quota usually gets filled up very quickly, if you use conda/pip environment as they generate a large number of residual files. They don’t remove them automatically and hence stay in your $HOME affecting your files quota.
We recommend you to clean your conda/pip cache files (if any). This cleaning up of cache files is very easy and needs only a single command to be run.
Following commands and links can come handy:
conda clean -a
pip cache purge
6.4. Installing Packages
To install larger packages, like Tensorflow, PyTorch you must first start an interactive job with adequate compute and memory resources to install packages. The login nodes restrict memory to 2GB per user, which may cause some large packages to crash.
Get a session
srun --cpus-per-task=2 --mem=8GB --time=04:00:00 --pty /bin/bash
You’ll be redirected to a compute node, wait to be assigned a node.
After getting a session, actiavte conda as described in the previous subtopic Activate conda.
Important
Make sure conda environment is activated buy running
which pip
orwhich python
. These commands should return the location of your environment. If you are getting/share/apps/anaconda3/2020.07/bin/python
please do not proceed.Now you can install packages (refer Cheatsheet).
Important
ipykernel
is required to run Open OnDemand Jupyter Notebooks, please install this package to your environment if haven’t already.
6.5. Cheatsheet
Most used conda commands are listed below for quick reference.
6.5.1. Quick Start
Command |
Description |
---|---|
|
verify conda install and check version |
|
create a new environment |
|
create environment with Python version 3.8 |
|
activate environent |
|
reactivate base environment |
6.5.2. Package Management
Command |
Description |
---|---|
|
install packages |
|
install packages from specified channel |
|
install specific version of package |
|
uninstall package |
|
list installed packages |
|
update all packages of current environment |
6.5.3. Environment Management
Command |
Description |
---|---|
|
list all environments and locations |
|
clone environment |
|
list revisions made to environment |
|
restore environment to a revision |
|
delete environment by name |
|
export current activated environment with platform and package specificity |
|
export deactivated envireonment as platform and package specific environment |
|
export current activated environment as cross-platform compatible environment |
|
import environment from a .yml file |
6.5.4. Maintenance
Command |
Description |
---|---|
|
remove all unused files and free-up space |
|
examine conda configuration |
Note
A more comprehensive documentation is available here.