Managing Conda Environments on ARC

This page provides guidance for creating, managing, and using Conda environments on ARC systems using Miniforge or Miniconda—both lightweight, open-source alternatives to Anaconda.

1. Why Miniforge or Miniconda (and Not Anaconda)
2. Create a conda environment specifically for the type of node where it will be used
3. GPU and CUDA Compatibility
4. Use a Jupyter kernel to load a conda environment in a Jupyter application
5. Using Conda Environments Inside Slurm Batch Scripts
6. Compatibility Note: Miniforge and Miniconda
7. Summary


1. Why Miniforge or Miniconda (and Not Anaconda)

ARC supports Miniforge and Miniconda because they provide the conda package manager without the proprietary Anaconda defaults channel. Both are lightweight, open-source, and fully supported through ARC’s module system.

  • Miniforge uses only the conda-forge channel and is the recommended choice for most users.

  • Miniconda provides the minimal conda bootstrap and can be configured to use conda-forge exclusively.

Note: The Anaconda defaults channel requires a paid institutional license. If you install Anaconda locally, remove the defaults channel to comply with licensing terms.

To view available modules:

module spider Miniforge
module spider Miniconda

To load a module:

module load Miniforge3
# or
module load Miniconda3

2. Create a conda environment specifically for the type of node where it will be used

Each of ARC’s clusters has at least two different node types. Each node type is equipped with a different cpu micro-architecture, slightly different operating system and/or kernel versions, slightly different system configuration and packages. All are tuned to be customized and efficient for the particular node features. These differences make Conda environments non-portable across node types.

Therefore, you must create and install your Conda environment on a compute node of the same node type where you intend to run it.

Example

If you plan to use an environment on TinkerCliffs a100_normal_q, you must build it on an a100_normal_q node.

Common Commands

Command

Purpose

interact

Obtain an interactive shell on a compute node

module spider

Search for available Miniforge/Miniconda modules

module load <module_name>

Load the selected module

conda create -p $HOME/envname

Create a new conda environment at the provided path

source activate <env_name or env_path>

Activate the environment

conda install ...

Install packages

conda env list

List available environments

conda list

List installed packages

The following steps will guide through creating and using a conda environment on TinkerCliffs’ A100 nodes:

Step 1 — Start an Interactive Session

interact --partition=a100_normal_q --nodes=1 --ntasks-per-node=4 --gres=gpu:1 --account=jdoeacct

Step 2 — Load Miniforge or Miniconda

module load Miniforge3
# or
module load Miniconda3

Step 3 — Create the Environment

conda create -p ~/.conda/envs/a100_env python=3.12

Step 4 — Activate the Environment

Always activate the conda environments on ARC using source activate ... not conda activate ....

source activate ~/.conda/envs/a100_env

Step 5 — Install Packages

conda install <package_name>

If a package is not available through Conda:

pip install <package_name>

Step 6 — Deactivate the Environment

conda deactivate

Step 7 — End the Interactive Session

exit

3. GPU and CUDA Compatibility

While nvidia-smi will display a version of CUDA, this is just the base CUDA on the node and can be overridden by

  • loading a different CUDA module: module spider cuda

  • activating an Anaconda environment which has cudatoolkit conda list cudatoolkit

  • installing a conda package built with a different cuda: conda list tensorflow -> check the build string

Check CUDA version in TensorFlow:

import tensorflow as tf

# This will print out various build and version information
print("TensorFlow version:", tf.__version__)
print("CUDA built with:", tf.sysconfig.get_build_info()["cuda_version"])
print("cuDNN built with:", tf.sysconfig.get_build_info()["cudnn_version"])

Check CUDA version in PyTorch:

import torch

# Print PyTorch version and the CUDA version it was compiled with
print("PyTorch version:", torch.__version__)
print("CUDA version (compiled):", torch.version.cuda)

# Check if CUDA is available and the runtime version
print("Is CUDA available?", torch.cuda.is_available())
if torch.cuda.is_available():
    print("CUDA runtime version (from driver):", torch.cuda.get_device_properties(0).major, ".", torch.cuda.get_device_properties(0).minor)

Install a specific CUDA toolkit if required:

conda install cudatoolkit=12.1

4. Use a Jupyter kernel to load a conda environment in a Jupyter application

You can use a Jupyter kernel to use a virtual environment inside a Jupyter notebook. Each kernel can be used to run different cells according to its language/package requirements. For example, if you have a notebook that uses two different sets of packages where each set is installed in a different conda environment, then you can use Jupyter kernels to switch between those two sets of packages.

To start a kernel that is associated with a specific environment, activate the environment and install ipykernel inside that environment:

Step 1 — Start an interactive session, load Conda, and activate the environment

interact --partition=a100_normal_q --nodes=1 --ntasks-per-node=4 --gres=gpu:1 --account=jdoeacct
module load Miniconda3
source activate ~/.conda/envs/a100_env

Step 2 — Install ipykernel

conda install ipykernel

Step 3 — Register the Kernel

python -m ipykernel install --user --name a100_env --display-name "Python (a100_env)"

Step 4 — Select in Jupyter

In Jupyter (via Open OnDemand), select from the top menu: Kernel → Change Kernel → Python (a100_env)), then execute your cell.


5. Using Conda Environments Inside Slurm Batch Scripts

When running jobs through Slurm, you may use your Conda environment in the same way you would in an interactive session. The only requirements are:

  1. Load the same module (Miniforge3 or Miniconda3) that you used to create the environment.

  2. Activate the environment using source activate, not conda activate.

This ensures that the correct Conda executable, Python interpreter, and packages are available during job execution.

Example Slurm Batch Script

#!/bin/bash
#SBATCH --job-name=my_conda_job
#SBATCH --partition=a100_normal_q
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --gres=gpu:1
#SBATCH --time=02:00:00
#SBATCH --account=myaccount

# Load the same module used when creating the environment.
module load Miniforge3
# module load Miniconda3   # Use this instead if your environment was built with Miniconda

# Activate your Conda environment
source activate /home/$USER/.conda/envs/a100_env

# (Optional) Display environment details for debugging
echo "Using Conda from: $(which conda)"
echo "Using Python from: $(which python)"
python --version

# Run your application
python my_script.py

6. Compatibility Note: Miniforge and Miniconda

Although Miniforge and Miniconda both provide Conda, they are not fully interchangeable.

Scenario

Expected Behavior

Recommendation

Create with Miniforge → Use with Miniforge

Reliable

Best practice

Create with Miniconda → Use with Miniconda

Reliable

Best practice

Create with one → Use with the other (same Conda version)

Usually works

Not recommended

Different Conda/Python versions across modules

May fail or behave inconsistently

Not recommended

Best Practice:
Always load the same module that was used when the environment was created.


7. Summary

  • Use Miniforge or Miniconda (not Anaconda) on ARC.

  • Create environments on the correct node type, and remember that envorinments are not portable from one partition to another, even if they are in the same cluster.

  • Do not create Conda environments inside batch scripts. Environments should be created interactively on the correct node type.

  • Always load the same module (Miniforge3 or Miniconda3) before activating a Conda environment.

  • Store environments in ~/.conda/envs or project directories.

  • Use ipykernel to integrate environments with Jupyter.

  • Load the same Conda module used during environment creation.

  • Use source activate rather than conda activate for compatibility with module-based Conda installations.