Miniconda Environment Set Up
- 1 What is Miniconda?
- 2 Downloading miniconda repo
- 3 Enabling the Miniconda environment
- 4 Setting up the Miniconda environment
- 5 Activate the conda environment
- 6 Install abinit in conda environment
- 7 Deactivate conda environment
- 8 Testing miniconda environment in an interactive Slurm job
- 9 Submission Script Example:
This article will explain how to set up the Miniconda Conda environment under a user’s HPC account.
In addition, this article will also show an example of a submission script that will show how to submit Miniconda job(s).
What is Miniconda?
Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others.
Downloading miniconda repo
#1
curl -L -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda3
#2
With Miniconda installed to a user’s home directory, the PATH environment variable would need to be exported to add miniconda to the PATH environment variable:
export PATH=$HOME/miniconda3/bin:$PATH
Enabling the Miniconda environment
conda init bash
Log off of HPC terminal and log back into HPC.
The terminal prompt on HPC should change to look like the following:
(base) [netidhere@cn(or gpu) XXX ~]$
The (base) confirms miniconda installed successfully and is in the default Conda environment.
Setting up the Miniconda environment
Here is an example showing how to create a Conda environment called abinit to allow for a abinit install:
conda create --name abinit
If you would like a miniconda environment to have a specific version of python, the following command can be entered instead, which will install Python 3.9 within the abinit conda environment:
conda create -n abinit python=3.9
Activate the conda environment
conda activate abinit
Terminal should change to look like the following:
(abinit) [netidhere@cn(or gpu) XXX ~]$
Install abinit in conda environment
Install abinit:
conda install abinit
or
conda install -c conda-forge abinit
The above should set up the Abinit environment with the needed dependencies.
Then a user should be able to call the abinit command(s) that are needed to run abinit successfully.
Deactivate conda environment
To deactivate the abinit conda environment, the following command can be entered:
conda deactivate
That will tell miniconda to go back to the (base) Conda environment and at that point a new Conda environment can be installed or activated.
Testing miniconda environment in an interactive Slurm job
srun -N 1 -n 24 -p general
conda activate condaenvironmentname
commands for conda/program run
To exit out of the Slurm job and end miniconda:
Type exit twice to exit out of the conda environment, and then exit out of the Fisbatch job.
User will be back on the login node they logged into HPC initially (login4, login5, login6)
Next time a user logs into HPC, the terminal will show the (base) [netidhere@cnXXX ~] on the login node.
Submission Script Example:
Here are the Bash Submission script steps to call the miniconda environment:
#!/bin/bash
#SBATCH --partition=partitionnamehere
#SBATCH -N 1
#SBATCH -n 24
module purge
module load modulesneededhere
source /gpfs/homefs1/yournetidhere/miniconda3/etc/profile.d/conda.sh
conda activate condaenvironment
softwarecommandhere