Use examples¶
It is now time to use the containers built in the Build examples section to compile some Rat C++ projects.
Hint
The content of the rat-containers/work directory is ignored by Git so feel free to use it as a playground to experiment.
Use the
--nvflag to mount CUDA libraries from host and enable GPU acceleration when running calculations on HPC.
Rat-Template¶
A good exercise is to compile the Rat-Template repository from Project-Rat group. It defines a simple program to simulate a solenoid and calculate field values over its mesh.
This can be done with the rocky-cuda-project-rat.sif image.
From the root of the repository, enter an interactive shell:
singularity shell -B $(pwd):/io singularityCE/rocky-cuda-project-rat.sif
# Optional: colored prompt and aliases
source env.sh
Navigate into the
worksubdirectory:
cd work
Clone the Rat-Template repository and navigate into it:
git clone https://gitlab.com/project-rat/rat-template.git
cd rat-template
Configure the project using
cmakefollowing Rat-Template instructions, or following the definition files:
cmake -B build -S . -G Ninja
Note
One might need to modify the CMakeLists.txt configuration
file in order to match the versions of the Rat libraries
installed inside the container.
Build the project:
cmake --build build
Run the project:
./bin/solenoid --od ./mydata
pyRat¶
The rocky-cuda-pyrat image adds UV and PatchELF to build
pyRat wheels against the Rat libraries installed in it.
Warning
Not usable with pyRat 2.0 until the recipes are updated: the image installs Rat 2.x, and pyRat 2.0 needs Rat 3.004.2 or later.
Once it installs a recent Rat:
From the root of the repository, enter an interactive shell:
singularity shell -B $(pwd):/io singularityCE/rocky-cuda-pyrat.sif
# Optional: colored prompt and aliases
source env.sh
Clone the pyRat repository in the
worksubdirectory:
cd work
git clone https://gitlab.com/project-rat-extras/pyrat.git
cd pyrat
Build a wheel against the Rat install prefix of the image:
uv run scripts/build_wheel.py --prefix <Rat install prefix> -p 3.14 --stubs
See Scripts for the other options.