---
title: "Miniconda Environment Set Up"
canonical: "https://kb.uconn.edu/space/SH/26079723879/Miniconda%20Environment%20Set%20Up"
format: markdown
---
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.

## Submit an interactive SLURM job

Users are not allowed to run programs on the login nodes, so an interactive SLURM job would need to be used.

```
srun -N 1 -n 126 -p general --pty bash
```

Wait for a compute node to assign.

## Download the Miniconda Repository

```
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
```

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. (Close the terminal and open a new one)

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 packages in conda environment

To install the package `abinit`:

```
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 10 -p general --pty bash

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=general
#SBATCH --ntasks=24
#SBATCH --nodes=1

module load required_modules_here

source ~/miniconda3/etc/profile.d/conda.sh
conda activate conda_environment

# run your software here
```