CPU (NumPy) vs GPU (PyTorch/CUDA) Monte Carlo pi estimation demos + benchmarks.
- Python: 3.11+
Using uv (recommended):
uv syncUsing pip:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt- Simple demo:
python -m examples.simple_demo- Benchmark (writes JSON into
results/):
python -m pi_estimation.benchmark- Plots (reads JSON and writes PNGs into
results/):
python -m pi_estimation.visualizeIf torch.cuda.is_available() is False, everything will still run in CPU-only mode.
To use CUDA, install a CUDA-enabled PyTorch build appropriate for your system (see PyTorch install instructions).