Skip to content

Installation

hr2d has been tested on Linux (RHEL 8) with NVIDIA V100, A100 and Quadro RTX 8000 GPUs, Python 3.11, PyTorch 2.5.1 and CUDA 12.4. An NVIDIA GPU is required for real datasets.

GPU installation

We recommend a fresh conda (or mamba) environment, with PyTorch installed first for your CUDA version, so that pip does not pick a PyTorch build that does not match your driver:

mamba create -n hr2d python==3.11
mamba activate hr2d
pip install torch --index-url https://download.pytorch.org/whl/cu124   # insert your CUDA version!
pip install hr2d

To find your CUDA version, run nvidia-smi: the version appears in the top right corner of the output. Check that PyTorch sees the GPU:

python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name())"

The paper's version

The paper's results were obtained with the version tagged paper-runs. To install exactly that version, install it from GitHub:

pip install "hr2d @ git+https://github.com/Lederman-Group/HR2D.git@paper-runs"

Editable installation

To change the code, or to use the analysis scripts in scripts/ (they are not installed by pip):

git clone https://github.com/Lederman-Group/HR2D.git
cd HR2D
pip install -e ".[dev]"
pytest tests            # on a GPU node

Running on a SLURM cluster

scripts/slurm/run.sbatch runs hr2d run on one GPU. Set HR2D_ENV to the environment where hr2d is installed, adjust the partition at the top of the script to your cluster, and submit it from the repository:

export HR2D_ENV=/path/to/conda_envs/hr2d
sbatch scripts/slurm/run.sbatch config.yaml            # add --resume to continue a run

Memory

hr2d keeps the preprocessed particles on the GPU when they fit in 40% of its free memory, and otherwise streams them in chunks from host memory or from the original stacks (see particles_on_gpu and particle_storage in 2D classification). Nothing is written to disk.