Software Exercise 3.2: Singularity Examples on OSG Connect¶
Background¶
The previous exercise (3.1) illustrated the idea of using containers, but didn't run a specific software program. In this exercise, you can choose one or more sample programs to run using a container.
Setup¶
-
Make sure you are logged into
login05.osgconnect.net. -
To get an idea on what container images are available on the OSG, take a look at this list or the names listed at the directory path
/cvmfs/singularity.opensciencegrid.org/opensciencegrid.
If you want to use your own container on the OSG, ask one of the school staff about how to do so.
- For all three examples, make sure you have the Singularity
requirementfrom the previous exercise) in your submit file, and you'll still be using the+SingularityImageflag.
Option 1: R¶
-
Create the following R script, called
simple.R:#!/usr/bin/env Rscript inputs = c(5, 19, 108, 42, 77) results = sum(inputs) print(results) -
In your submit file, set the R script as the executable:
executable = simple.RWe can use the R script directly (without another wrapper script) because we included the header
#!/usr/bin/env Rscriptat the top of our script file. This is a special indicator that the script should be run using theRscriptprogram. -
Choose one of the existing R containers to run the job:
+SingularityImage = "/cvmfs/singularity.opensciencegrid.org/opensciencegrid/osgvo-r:4.0.2" -
Submit the job and check the standard output file when it completes.
Option 2: GROMACS¶
Example taken from alchemistry.org
-
Create the following bash script, called
run_gromacs.sh:#!/bin/bash gmx grompp -f ethanol.0.mdp -c ethanol.gro -p ethanol.top -o ethanol.0.tpr -maxwarn 4 -
Unzip the input files, and move them to the current directory:
username@login $ tar -xzf /public/osgvs21/gromacs_input.tgz username@login $ cp gromacs_input/* ./ -
In your submit file, set the
run_gromacs.shscript as the executable: -
Add the input files to the appropriate line in the submit file.
-
Choose the GROMACS container to run the job:
+SingularityImage = "/cvmfs/singularity.opensciencegrid.org/opensciencegrid/osgvo-gromacs:latest" -
Submit the job and check the standard output file when it completes.
Those who want a little extra challenge - this example is meant to be run 9 times, per the tutorial link above. Read through the first paragraph of the tutorial and try to modify this submit file (and input files) so that it runs 9 jobs, each with a different
init-lambda-statevalue in theethanol.X.mdpfile.
Option 3: Cowsay¶
One final (fun) example - running the program "cowsay" from a container.
-
Create the following R script, called
cowsay.sh:#!/bin/bash cowsay "Computing is Fun" -
Make
cowsay.shyour executable. -
Choose the
lolcowcontainer to run the job:+SingularityImage = "/cvmfs/singularity.opensciencegrid.org/sylabsio/lolcow:latest" -
Submit the job and check out the output when it completes!
Note: it's possible to run jobs using containers (like this one) without using a wrapper script. If we wanted to run the
cowsayprogram, directly as the executable, it would look like this::::file executable = /usr/games/cowsay arguments = "Computing is Fun" transfer_executable = false
+SingularityImage = "/cvmfs/singularity.opensciencegrid.org/sylabsio/lolcow:latest/"
Note that this example is slightly different than our previous scripts; here we're using cowsay directly from the container. Since it's not a separate executable, we need to add the
transfer_exectuable = falseoption