Skip to content

Software Exercise 3.2: Singularity Examples on OSG Connect


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.


  1. Make sure you are logged into

  2. 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/

If you want to use your own container on the OSG, ask one of the school staff about how to do so.

  1. For all three examples, make sure you have the Singularity requirement from the previous exercise) in your submit file, and you'll still be using the +SingularityImage flag.

Option 1: R

  1. Create the following R script, called simple.R:

    #!/usr/bin/env Rscript
    inputs = c(5, 19, 108, 42, 77)
    results = sum(inputs)
  2. In your submit file, set the R script as the executable:

    executable = simple.R

    We can use the R script directly (without another wrapper script) because we included the header #!/usr/bin/env Rscript at the top of our script file. This is a special indicator that the script should be run using the Rscript program.

  3. Choose one of the existing R containers to run the job:

    +SingularityImage = "/cvmfs/"
  4. Submit the job and check the standard output file when it completes.

Option 2: GROMACS

Example taken from

  1. Create the following bash script, called

    gmx grompp -f ethanol.0.mdp -c ethanol.gro -p -o ethanol.0.tpr -maxwarn 4
  2. 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/* ./
  3. In your submit file, set the script as the executable:

  4. Add the input files to the appropriate line in the submit file.

  5. Choose the GROMACS container to run the job:

    +SingularityImage = "/cvmfs/"
  6. 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-state value in the ethanol.X.mdp file.

Option 3: Cowsay

One final (fun) example - running the program "cowsay" from a container.

  1. Create the following R script, called

    cowsay "Computing is Fun"
  2. Make your executable.

  3. Choose the lolcow container to run the job:

    +SingularityImage = "/cvmfs/"
  4. 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 cowsay program, directly as the executable, it would look like this:

:::file executable = /usr/games/cowsay arguments = "Computing is Fun" transfer_executable = false

+SingularityImage = "/cvmfs/"

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 = false option