Skip to content

Singularity / Apptainer

Our Docker containers are converted to Singularity/Apptainer containers and stored on object storage.

First get an overview of which containers are available as Singularity containers in neurocommand/cvmfs/log.txt:

Terminal window
curl -s https://raw.githubusercontent.com/neurodesk/neurocommand/main/cvmfs/log.txt

Assign the container name to a variable:

Terminal window
export container=itksnap_3.8.0_20201208

Then download the container. One way is to use curl:

Terminal window
curl -X GET https://neurocontainers.neurodesk.workers.dev/$container.simg -O

Some of our containers contain GPU-accelerated applications. Here is an example that tests the GPU-accelerated program eddy in FSL:

Terminal window
curl -X GET https://neurocontainers.neurodesk.workers.dev/fsl_6.0.5.1_20221016.simg -O
git clone https://github.com/neurolabusc/gpu_test.git
singularity shell --nv fsl_6.0.5.1_20221016.simg
cd gpu_test/etest/
bash runme_gpu.sh

When NVIDIA drives your X display, container OpenGL GUIs need --nv, even without CUDA use. Images include Mesa’s GLX library, but the NVIDIA X server requires libGLX_nvidia.so.0. Without it, GUIs fail. Look for GLX or libGLX_nvidia.so.0 in diagnostic output.

The --nv option supplies the host’s NVIDIA libraries. For a downloaded image, run:

Terminal window
apptainer exec --nv "$container.simg" itksnap

For Singularity, replace apptainer with singularity. For Neurocommand wrappers, set this in the terminal you use to launch applications:

Terminal window
export neurodesk_singularity_opts="${neurodesk_singularity_opts:+$neurodesk_singularity_opts }--nv"

For Apptainer, including CVMFS module wrappers, alternatively use:

Terminal window
export APPTAINER_NV=1

If this causes a GLIBC_2.38 error, see the Ubuntu compatibility guidance. Details are in neurocommand issue #810.

The Singularity containers can also be used in combination with our Transparent Singularity Tool, which wraps the executables inside a container so they are easily available to pipelines.

One example:

Terminal window
curl -s https://raw.githubusercontent.com/neurodesk/neurocommand/main/cvmfs/log.txt
export container=itksnap_3.8.0_20201208
git clone https://github.com/neurodesk/transparent-singularity ${container}
cd ${container}
./run_transparent_singularity.sh ${container}