---
# System prepended metadata

title: HPC Python - Numba
tags: [NAISS Training, workshop]

---

# HPC Python - Numba

## Pelle

https://uppmax.github.io/HPC-python/day4/gpu.html#numba-example

```bash
salloc -A uppmax2025-2-393 -t 00:30:00 -n 2 -p gpu --gpus=l40s:1
```

## Build
[Numba+CUDA build instructions](https://nvidia.github.io/numba-cuda/user/installation.html#numba-cuda-installation)

```bash
module load Python/3.13.5 foss/2025b CUDA/13.0.2
python3 -m venv numba-gpu
source numba-gpu/bin/activate
pip3 install --upgrade pip setuptools wheel
pip3 install numba-cuda[cu13] numpy
```


## Exercises
```bash

$ module load Python/3.13.5 foss/2025b CUDA/13.0.2
$ source /sw/arch/local/software/python/venvs/numba-gpu/bin/activate

$ python add-list.py 
CPU function took 17.475140 seconds.
GPU function took 0.134774 seconds.


$ python integration2d_gpu.py 
Integral value is 3.783339e-08, Error is 3.783339e-08
Time spent: 1.02 sec

$ python integration2d_gpu_shared.py 
Integral value is -2.094257e-08, Error is 2.094257e-08
Time spent: 1.03 sec

```