Repository navigation
Installation and Containers
Back to Home · Next: Quickstart
-
OS: Linux x86_64 (GPU runtime requires NVIDIA Driver + CUDA Toolkit
nvcc; CPU-only build also works on Linux/macOS) -
Python:
>= 3.12with development headers (Python.hfrompython3.12-devor Conda) -
C/C++ Toolchain & Libraries:
gcc/g++, GNU Scientific Library (libgsl-dev), FFTW3 single-precision (libfftw3-devprovidinglibfftw3f),pkg-config -
Python runtime packages (installed automatically via
pyproject.toml):numpy>=2.0,scipy,astropy>=2.0,h5py>=2.8.0,cffi>=1.0,classy>=3.3.4,<3.4,hmf>=3.6.2,cosmotile>=0.2.5,cyclopts,attrs,click,matplotlib,tqdm,pyyaml,tomlkit
Zero external Python GPU dependencies:
cupyandnumbaare not required. Multi-GPU / multi-node NCCL 2.x support (libnccl.so.2 >= 2.7) is also discovered lazily at runtime viadlopenwith no build-timenccl.horlibnccl-devrequirement.
git clone https://github.com/HainaHuang729/21cmCU.git
cd 21cmCU
./scripts/install.shUseful flags:
-
--cuda-archs 89— target a specific SM compute capability (autoby default, queryingnvidia-smi) -
--venv .venv— create and activate a fresh Python 3.12 virtual environment first -
--cpu— build CPU-only (USE_CUDA=0) even ifnvccis installed
The script verifies Python >= 3.12, Python.h, gcc, libgsl, libfftw3f, and nvcc, runs pip install -e . --no-build-isolation, and executes python -m py21cmcu.cli doctor to validate the installation.
export USE_CUDA=1
export CUDA_ARCHS="80,86,89,90" # or CUDA_ARCHS=auto
pip install -e . --no-build-isolationsetup.py / build_cffi.py automatically discovers the highest CUDA installation under /usr/local/cuda*, queries nvidia-smi for SM architectures when CUDA_ARCHS=auto, and resolves GSL/FFTW headers via environment paths, active conda/venv prefixes, or pkg-config.
Pre-built container recipes under docker/ avoid local compiler/header setup:
docker build -f docker/Dockerfile --build-arg CUDA_ARCHS="80,86,89,90" -t 21cmcu:1.0.0 .
docker run --rm --gpus all 21cmcu:1.0.0 doctorDefaults baked into the image: P21_USE_CUDA=1, P21_CUDA_MODE=fast, OPENBLAS_NUM_THREADS=1.
apptainer build 21cmcu.sif docker/21cmcu.def
apptainer run --nv 21cmcu.sif doctor --as-json
srun --gres=gpu:2 apptainer run --nv 21cmcu.sif python examples/03_multigpu_large_ic.py --dim 1536 --devices 0,121cmcu version
21cmcu doctor
21cmcu doctor --as-json21cmcu doctor prints:
-
py21cmcu, Python, and NumPy versions + CPU count - CUDA compile/runtime status, visible device count, and GPU names/VRAM/compute capability
-
nvidia-smi topo -minterconnect topology (NODE,SYS,PHB,PIX,NV#) when$\ge 2$ GPUs are present -
nvcc,gcc,libgsl, andlibfftw3fshared-library discovery - Recommended 24 GB GPU count and host RAM across
512³–2048³grids
21cmCU v1.0.0 · Native C/CUDA + cuFFT Engine for 21cmFAST v4 · See CHANGELOG.md and BENCHMARKS.md in the main repository.
Getting Started
Simulation & Science Pipelines
- Precision Modes & Calibration
- Multi-GPU & Large Grids
- Distributed NCCL & Multi-Node
- Residency & I/O
- SBI & Batch Pipeline
- Bayesian Inference & Samplers
- Multi-Probe, Fisher & Topology
- Interferometer Mock & Forecast
- Lightcone Optimization & 3D Viz
Reference