User installed software
You can install software that doesn't require sudo privileges in any of these storage locations,
- Group storage,
/hpc/group/<groupname>. This is the best choice for lab specific software, or when a group wants to strongly control software versions and packages. Use a subdirectory such as/hpc/group/<groupname>/$USERfor your personal installs. - Your home directory,
/hpc/home/$USER. It has a 25 GB quota, and conda environments can fill it quickly. - Doctoral storage,
/hpc/dctrl/$USER, if you're a PhD student.
Python with Miniforge
Use conda environments to manage Python versions and packages for both SSH and OnDemand. We recommend Miniforge, a minimal conda installer that uses the community conda-forge channel by default and includes mamba. Miniconda and Anaconda default to Anaconda's defaults channel, which has licensing terms for large organizations.
Install Miniforge
Log in to the DCC and set PREFIX to the install location you chose and run the installer,
PREFIX=/hpc/group/<groupname>/$USER/miniforge3 # or ~/miniforge3, or /hpc/dctrl/$USER/miniforge3
mkdir -p "$(dirname "$PREFIX")"
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
bash Miniforge3-Linux-x86_64.sh -b -p "$PREFIX"
"$PREFIX/bin/conda" init bash
rm Miniforge3-Linux-x86_64.sh
conda init adds a block to your ~/.bashrc. Log out and log back in, and your prompt should start with (base).
If you already have Miniconda or Anaconda installed, you can install Miniforge alongside it and recreate your environments there. Remove the old conda block from ~/.bashrc so only one installation is initialized.
Create an environment
In the example below, myenv is the name of the environment and python=3.12 is the Python version.
Your prompt shows the active environment,
With the environment active, install packages with conda install (or mamba install) or pip install. Each environment has its own pip, so packages installed with it stay inside that environment. Use conda deactivate to leave the environment.
For more information, see Managing Environments in the conda user guide.
Use the environment in a batch job
Batch scripts don't read ~/.bashrc, so conda activate is undefined until you load conda's shell functions. Either source conda's setup script directly,
#!/bin/bash
#SBATCH --partition=common
#SBATCH --mem=4G
source "$(conda info --base)/etc/profile.d/conda.sh"
conda activate myenv
python my_script.py
Or, since conda init added conda to your ~/.bashrc, source that instead of conda.sh,
Sourcing ~/.bashrc also runs anything else in it, such as aliases or module load lines. Use conda.sh if you want the job environment to depend only on conda.
Use the environment in Jupyter
To make an environment available as a kernel in Jupyter Lab on OnDemand, see Using your own Python environment.
Troubleshooting
conda is not recognized after installing Miniforge
The conda initialization in ~/.bashrc only runs in a bash shell. Check your login shell at https://idms-web-selfservice.oit.duke.edu/ under Advanced IT Options > Current UNIX Shell > Edit, and select /bin/bash. Then log in to the DCC again.
If conda init didn't run, run it again with the PREFIX you installed to, then log back in,