Skip to content

Software Exercise 4.1: 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

  1. Make sure you are logged into login04.osgconnect.net.

  2. To get an idea on what container images are available on the OSG, take a look at the directory path /cvmfs/singularity.opensciencegrid.org/opensciencegrid.

If you want to use your own container on the OSG, message your mentor or the general slack channel 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)
    print(results)
    
  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/singularity.opensciencegrid.org/opensciencegrid/osgvo-r:4.0.2"
    
  4. Submit the job and check the standard output file when it completes.

Option 2: GROMACS

Example taken from alchemistry.org

  1. 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
    
  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 run_gromacs.sh 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/singularity.opensciencegrid.org/opensciencegrid/osgvo-gromacs:latest"
    
  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.sh:

    #!/bin/bash
    
    cowsay "Computing is Fun"
    
  2. Make cowsay.sh your executable.

  3. Choose the lolcow container to run the job:

    +SingularityImage = "/cvmfs/singularity.opensciencegrid.org/sylabsio/lolcow:latest"
    
  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/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 = false option