Run an executable under Apptainer on GPU
This article describes how to run an applicatiopn that was compiled in an Apptainer environment on a GPU.
Example application¶
We'll use the fidibench set of benchmarks to illustrate the process. On mahuika,
git clone https://github.com/pletzer/fidibench
cd fidibench
mkdir build-nv
cd build-nv
A container with NVIDIA compilers can be obtained here /nesi/nobackup/pletzera/ngarch_nvhpc.sif
. To launch the container:
module purge
module load CUDA/12.6.3 Apptainer/1.2.5
apptainer shell --nv /nesi/nobackup/pletzera/ngarch_nvhpc.sif
--nv
option which exposes the GPU hardware to the container.
We can now build an application using the nvc++
compiler inside the container:
Apptainer> CXX=nvc++ cmake -DOPENACC=1 ..
Apptainer> cd upwind/cxx
Apptainer> make upwindAccCxx
Apptainer> exit
upwindAccCxx
) contains OpenACC directives to offload to a GPU.
Run the application¶
srun --gpus-per-node=A100-1g.5gb:1 apptainer exec --nv \
/nesi/nobackup/pletzera/ngarch_nvhpc.sif ./upwind/cxx/upwindAccCxx
number of cells: 128 128 128
number of time steps: 10
check sum: 1