In the previous article, I described how to prepare a single-GPU workstation capable of running both CryoSPARC and RELION.
This post focuses on installing and testing RELION 5.0, including the Miniforge setup, Conda environment creation, CMake build, and running the official tutorial dataset in the correct order.

The installation steps were recorded from my own workstation configuration and verified with
the official RELION documentation
and K. B. Wong’s Cryo-EM workstation setup notes.


1. Checking Required Packages

Before building RELION, it is important to confirm that all required system packages are installed.
The following bash script automatically checks each dependency.

#!/bin/bash

packages=(
    "build-essential"
    "cmake"
    "gfortran"
    "libgtk-3-dev"
    "libfftw3-dev"
    "libgsl-dev"
    "libjpeg-dev"
    "libpng-dev"
    "libtiff-dev"
    "python3"
    "python3-pip"
)

for package in "${packages[@]}"; do
    if dpkg -s "$package" > /dev/null 2>&1; then
        echo "$package is installed."
    else
        echo "$package is NOT installed."
    fi
done

python_packages=("numpy" "scipy" "matplotlib")
for pkg in "${python_packages[@]}"; do
    if python3 -c "try: import $pkg; print('Installed') except ImportError: print('Not Installed')" | grep -q "Installed"; then
        echo "python3-$pkg is installed."
    else
        echo "python3-$pkg is NOT installed."
    fi
done

If all packages are properly installed, the versions of CMake, GCC, and Python3 will be displayed.


2. Installing Miniforge

RELION 5.0 includes PyTorch-based features such as Blush Regularisation, so it is recommended to manage Python dependencies separately. Installing Miniforge ensures that Conda environments can be created easily and reproducibly.

cd ~
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh
source ~/.bashrc

At this point, we have only prepared Miniforge itself. The actual RELION environment will be created after downloading the source code.


3. Downloading RELION Source Code

Download RELION from the official GitHub repository. Here we will use version 5.0 as an example.

cd ~
git clone https://github.com/3dem/relion.git
cd relion
git checkout ver5.0
git pull

The RELION source directory contains an environment.yml file that defines the official Conda environment configuration (relion-5.0).


4. Creating and Activating the relion-5.0 Conda Environment

Create the Conda environment using the environment.yml file included with the source. This environment installs all required Python and PyTorch dependencies in versions verified by the RELION developers.

conda env create -f environment.yml
conda activate relion-5.0

⚠️ Important: The official RELION documentation advises not to modify this environment. It is carefully tuned for version compatibility and stability. Always activate this environment before running CMake.


5. Building and Installing RELION

With the relion-5.0 environment active, proceed to build RELION. CMake will automatically detect the correct Python and Torch paths from the environment.

cd ~/relion
mkdir build
cd build

Run CMake with appropriate paths for your system. Adjust the MotionCor2, CTFFIND4, and MPI locations as necessary.

cmake .. \
    -DCMAKE_INSTALL_PREFIX=$HOME/relion5 \
    -DMOTIONCOR2_EXECUTABLE=/opt/MotionCor2/MotionCor2 \
    -DMPI_C_COMPILER=/usr/bin/mpicc \
    -DCTFFIND4_EXECUTABLE=/usr/local/bin/ctffind \
    -DFETCH_WEIGHTS=OFF \
    -DCUDA_ARCH=89 \
    -DTORCH_HOME_PATH=$HOME/torch \
    -DFORCE_OWN_FLTK=OFF

💡 Note: CUDA_ARCH=89 corresponds to NVIDIA Ada Lovelace GPUs (e.g., RTX 4090). Modify this value for your specific GPU architecture.

Then compile and install:

make -j$(nproc)
make install

Finally, add RELION to your shell path:

echo 'export PATH="$HOME/relion5/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

6. Configuring CUDA and Library Paths

If CUDA libraries are not globally available, add the following lines to your .bashrc:

export PATH=/usr/local/cuda-12.9/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64:$LD_LIBRARY_PATH
source ~/.bashrc

This ensures that CMake and RELION can properly locate CUDA binaries and libraries.


7. Testing RELION with the Tutorial Dataset

Once installation is complete, test the build using the official RELION tutorial dataset.

wget ftp://ftp.mrc-lmb.cam.ac.uk/pub/scheres/relion30_tutorial_data.tar
tar -xf relion30_tutorial_data.tar

This dataset was collected using a JEOL Cryo-ARM (200 kV) microscope with the following parameters:

  • Pixel size: 0.885 Å/pixel
  • Voltage: 200 kV
  • Spherical aberration: 1.4 mm
  • Dose rate: 1.277 e⁻ / Ų / frame
  • Courtesy of Takayuki Kato (Namba Group, Osaka University)

CTF estimation was performed using:

/usr/local/bin/ctffind

8. Testing Blush Regularisation

RELION 5 introduces Blush Regularisation, improving stability and accuracy in 3D classification. The pretrained model weights are stored in:

mkdir -p ~/torch/hub/checkpoints/relion_blush

Run 3D Classification on the tutorial dataset to verify that RELION can access both CUDA and PyTorch correctly.


9. Performance and Stability Notes

Even on a single-GPU workstation, RELION 5 performs reliably for small- to medium-sized datasets. CPU utilization during reconstruction and CTF estimation is efficient, and GPU memory usage typically remains within 8–10 GB.

If memory allocation errors occur, try setting the following environment variables:

export OMP_NUM_THREADS=4
export RELION_ALLOC_DEBUG=1

Locking CUDA and NVIDIA driver versions is recommended to prevent segmentation faults caused by version mismatches.


10. Summary and Next Steps

Building RELION from source is more than an installation step—it provides deeper insight into the interaction among CUDA, MPI, and Python environments, and allows precise optimization of your workstation for research use.

With RELION successfully built and tested using the tutorial data, the workstation is now ready for the full Single-Particle Analysis (SPA) workflow.

In the next article, I will cover hands-on processing of the tutorial dataset, including 2D classification, 3D reconstruction, and resolution assessment. Now the real data processing begins.