Using a locally installed Conda virtual environment is highly recommended so that you can install the specific packages that you need.
You can also have more than one environment with different packages for testing purposes. This procedure uses the Anaconda module already loaded on Discovery.
Working with a Miniconda environment
This procedure assumes that you have not installed Miniconda previously. If you need to update Miniconda, don’t use the installation procedure. Use the
conda
update
command. This procedure uses the Miniconda3 version with Python version 3.8 in step 2, although there are other versions you can install, such as
Miniconda3 with Python 3.7.
To install Miniconda:
If you are on a login node, move to a compute node by typing
srun
--partition=short
--nodes=1
--cpus-per-task=1
--pty
/bin/bash
.
Type
wget
--quiet
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
to get the latest version of Miniconda.
Type
sha256sum
Miniconda3-latest-Linux-x86_64.sh
to check the hash key of the package.
Type
bash
Miniconda3-latest-Linux-x86_64.sh
-b
-p
<dir>
to start the installation, where
<dir>
should be replaced with the full path to your desired installation directory. For example, set it to
/work/<mygroup>/<mydirectory>/miniconda3
(recommended).
Type
source
<dir>/bin/activate
to activate the miniconda environment.
Another recommended step is to update your Conda version (possible only when using conda you own):
conda
update
conda
-y
After installing, activating and updating Miniconda, you can create a new virtual Conda environment. In the example below, the Conda envinronment is named “my-python38environment” and installs Python version 3.8.
After completing steps 1 through 6 in the previous procedure, type
conda
create
--name
my-python38environment
python=3.8
.
Type
y
if asked to proceed with the installation.
Type
conda
activate
my-python38environment
to activate the environment.
To deactivate the environment, type
conda
deactivate
. You can type this command again to deactivate the Miniconda environment.
Conda best practices
Your .conda directory may get very large if you install multiple packages and create many virtual Conda environments. Make sure to clean the Conda cache and clean unused packages with:
conda
clean
--all
.
Clean unused Conda environments by first listing the environments with:
conda
env
list
, and then removing unused ones:
conda
env
remove
--name
<yourenvironmentname>
.
You can build Conda environments in different locations to save space on your home directory (see
Storage Accessible on Discovery
). You can use the
--prefix
flag when building your environment. For example:
conda
create
myenv
--prefix=/work/<mygroup>/<mydirectory>
.
It is not recommended to build your Miniconda and virtual Conda environments inside your /home directory due to its limited space qouta (see
Storage Accessible on Discovery
). Use the /work file system instead. If your group needs access to /work, the group PI can request it using:
New Storage Space request
.