Ok let’s try freesurfer next.@solj is going to work on the binary compiles to provide traditional modules over time.
I’m going to provide containers and document how they are built. In a separate thread (and eventually via documentation and training) we will provide more background info on containers. But for now, just know that Containers are an OS-level virtualization paradigm that allow multiple, isolated user environments to run concurrently.
Using containers, we will be able to provide software faster and also provide it in a way that you can run the same containers on your laptop, desktop, on Europa, or out at TACC. It’s one big step towards creating reproducible workflows, reducing our support burden, and giving you the tools to support yourself. That’s one of the main themes of TRECIS.
Europa currently supports charliecloud and singularity containers. We also plan to support podman longer term.
For now, let’s focus on using Singularity. We are going to start with the Docker images available on the freesurfer dockerhub page. Going to tags, we see there are two versions available: 7.1.1 and 6.0
Let’s convert both of them to singularity images. To do this, we’re going to write singularity definition files.. Also, since freesurfer is licensed software, I’m also going to bake the license file into the singularity image. Finally, we also need to create a mount point inside our container for mounting $SCRATCH. $HOME is available by default when running singularity, but we have to pass extra flags to get access to $SCRATCH inside the container.
[csim@europa freesurfer]$ cat freesurfer-7.1.1.def
Bootstrap: docker
From: freesurfer/freesurfer:7.1.1
IncludeCmd: yes # Use the CMD as runscript instead of ENTRYPOINT
%setup
mkdir -p ${SINGULARITY_ROOTFS}/opt/freesurfer
mkdir -p ${SINGULARITY_ROOTFS}/scratch && chmod 777 ${SINGULARITY_ROOTFS}/scratch
chmod 644 license.txt
%files
license.txt /opt/freesurfer/.license
[csim@europa freesurfer]$ cat freesurfer-6.0.def
Bootstrap: docker
From: freesurfer/freesurfer:6.0
IncludeCmd: yes # Use the CMD as runscript instead of ENTRYPOINT
%setup
mkdir -p ${SINGULARITY_ROOTFS}/opt/freesurfer
mkdir -p ${SINGULARITY_ROOTFS}/scratch && chmod 777 ${SINGULARITY_ROOTFS}/scratch
chmod 644 license.txt
%files
license.txt /opt/freesurfer/.license
Now that we have our definition files, we can build our sif, our singularity image format file.
$ singularity build --fakeroot freesurfer-7.1.1.sif freesurfer-7.1.1.def
$ singularity build --fakeroot freesurfer-6.0.sif freesurfer-6.0.def
We now have two Singularity SIFs that can be used to invoke different versions of freesurfer.
Note: You can only run Singularity containers on compute nodes; if you need to run a container on the login nodes, you need to use podman or charliecloud
The containers that I publish will all be in /opt/ohpc/pub/containers. Now, let’s see how to run it.
First, let’s start an interactive slurm job and load the singularity module
[css180002@europa ~]$ srun -N1 --pty /bin/bash
[css180002@compute-1-1-1 ~]$ ml load singularity
[css180002@compute-1-1-1 ~]$
After that, you can call the singularity containers and either work with the container interactively, or have the container invoke a command and work directly on data on the host system.
[css180002@compute-1-1-1 ~]$ /opt/ohpc/pub/containers/freesurfer/sifs/freesurfer-7.1.1.sif freesurfer
FreeSurfer is a set of tools for the analysis and visualization
of structural and functional brain imaging data. FreeSurfer
also refers to the structural imaging stream within the
FreeSurfer suite.
Users should consult the online documentation available at:
http://surfer.nmr.mgh.harvard.edu
Alternatively, the 'recon-all' command help-text provides
adequate information to begin processing subject data, such
as the sample subject 'bert' found in the 'freesurfer/subjects'
directory. Type 'recon-all --help' to view this help-text.
Direct comments and questions to:
freesurfer@nmr.mgh.harvard.edu
You are running this version of FreeSurfer:
freesurfer-linux-centos7_x86_64-7.1.1-20200723-8b40551
[css180002@compute-1-1-1 ~]$ /opt/ohpc/pub/containers/freesurfer/sifs/freesurfer-7.1.1.sif recon-all --help
If you just invoke the container directly without passing arguments, it will put you inside the container but with access to the host filesystem.
Before running container directly.
[css180002@europa ~]$ srun -N1 --pty /bin/bash
[css180002@compute-1-1-1 ~]$ pwd
/home/css180002
[css180002@compute-1-1-1 ~]$ ls
containers hello.c local matlab miniconda src tmp
[css180002@compute-1-1-1 ~]$ ls /scratch/css180002/
git this_is_scratch tmp
[css180002@compute-1-1-1 ~]$ freesurfer
bash: freesurfer: command not found
After running container with no arguments.
[css180002@compute-1-1-1 ~]$ /opt/ohpc/pub/containers/freesurfer/sifs/freesurfer-7.1.1.sif
[css180002@compute-1-1-1 ~]$ pwd
/home/css180002
[css180002@compute-1-1-1 ~]$ ls
containers hello.c local matlab miniconda src tmp
[css180002@compute-1-1-1 ~]$ ls /scratch/
[css180002@compute-1-1-1 ~]$ freesurfer
FreeSurfer is a set of tools for the analysis and visualization
of structural and functional brain imaging data. FreeSurfer
also refers to the structural imaging stream within the
FreeSurfer suite.
Notice how $HOME is available inside the container but $SCRATCH isn’t? We can fix that by passing a -B
and using the singularity shell
command.
[css180002@compute-1-1-1 ~]$ singularity shell -B $SCRATCH:/scratch containers/freesurfer/sifs/freesurfer-7.1.1.sif
Singularity freesurfer-7.1.1.sif:~> ls /scratch/
git this_is_scratch tmp
Singularity freesurfer-7.1.1.sif:~> exit
[css180002@compute-1-1-1 ~]$
Alternatively, you can just set the $SINGULARITY_BINDPATH
environment variable and never worry about it again.
[css180002@compute-1-1-1 ~]$ export SINGULARITY_BINDPATH="$SCRATCH:$SCRATCH"
[css180002@compute-1-1-1 ~]$ /opt/ohpc/pub/containers/freesurfer/sifs/freesurfer-7.1.1.sif
[css180002@compute-1-1-1 ~]$ ls $SCRATCH
git this_is_scratch tmp