Creating and Using Conda Environments on Clipper
Conda environments provide a flexible way to manage Python projects and their dependencies on the Clipper HPC cluster.
Conda environments are isolated Python installations that allow for easy management of project-specific dependencies. They enable users to create a personalized environments without affecting the global Python installation available to all Clipper users. This way, users can manage multiple environments without affecting other projects or users.
This section describes how to create and use Conda environments on Clipper and how to access them through Jupyter.
Creating Conda Environments
Conda environments can be stored in your /mnt/home
folder or in project space allocated on /mnt/projects
.
To create a Conda environment, first load the Miniconda3 module:
[hpcuser1@clipper ~]$ module load miniconda3
Then, create the Conda environment. This example creates an environment named "mycondaenv" in the user's home directory:
[hpcuser1@clipper ~]$ conda create --prefix /mnt/home/hpcuser1/mycondaenv
Using Conda Environments
Activation and Deactivation
Conda environments must be activated to make the isolated Python interpreter and packages available in your shell.
To activate the environment, run:
[hpcuser1@clipper ~]$ conda activate /mnt/home/hpcuser1/mycondaenv
Your shell prompt will change to indicate you are in the Conda environment:
(/mnt/home/hpcuser1/mycondaenv) [hpcuser1@clipper ~]$
To deactivate the environment and return to the default state, type:
conda deactivate
Installing Packages
Because the Conda environment has been activated, the miniconda3 module is no longer loaded. Module load is used to load a specific software package or tool into your current shell environment, and because that environment has been changed the module must be loaded again. Before installing packages inside the environment, run:
module load miniconda3
Conda can now be used to install packages inside the environment. After activation, run:
conda install <package>
For example, to install the ipykernel package:
conda install -c anaconda ipykernel
Conda will handle the installation of ipykernel and all necessary dependencies.
Packages can also be removed from the Conda environment:
conda remove <package>
Using Conda Environments with Jupyter
To use your Conda environment with Jupyter, ipykernel must be installed and registered to provide Jupyter with the IPython kernel. To install, run:
conda install -c anaconda ipykernel
python -m ipykernel install --user --name "mycondaenv"
This will make your Conda environment available as a kernel option in Jupyter notebooks.
To access your Conda environment in Jupyter notebooks, see Accessing Jupyter Lab on Clipper
Note on Environment Persistence
Each time you start a new session or switch environments, you may need to reload the miniconda3 module to ensure conda is available:
module load miniconda3
conda activate /mnt/home/hpcuser1/mycondaenv
Conda Version Note
As of May 2024, the Miniconda3 version available on Clipper is 24.1.2. This version includes Python 3.9.18 by default, but other Python versions can be installed within Conda environments as needed.
If you require a different Conda or Python version, please contact Academic Research Computing support with your request and justification.