Difference between revisions of "Singularity Guide"

From Storrs HPC Wiki
Jump to: navigation, search
(Add vagrant instructions)
(Fix CentOS VM setup instructions)
Line 28: Line 28:
 
Requirements:
 
Requirements:
 
* Your computer with macOS, Windows, or a GNU/Linux operating system.
 
* Your computer with macOS, Windows, or a GNU/Linux operating system.
* [https://www.virtualbox.org/ VirtualBox] 1.9 or later to create a virtual machine in which we will install singularity.
+
* [https://www.virtualbox.org/ VirtualBox] to create a virtual machine in which we will install singularity.
* [https://www.vagrantup.com/ Vagrant] to greatly simplify administration of our virtual machine.
+
* [https://www.vagrantup.com/ Vagrant]( version 1.9 or later) to greatly simplify administration of our virtual machine.
 
* At least 40 GB of disk space.
 
* At least 40 GB of disk space.
  
Line 78: Line 78:
 
cd vm-singularity
 
cd vm-singularity
 
vagrant init centos/7
 
vagrant init centos/7
vagrant box add centos/7
+
vagrant box add --provider virtualbox centos/7
  
 
# Build and start the Vagrant hosted VM
 
# Build and start the Vagrant hosted VM
Line 85: Line 85:
 
# Run the necessary commands within the VM to install Singularity
 
# Run the necessary commands within the VM to install Singularity
 
vagrant ssh -c /bin/sh <<EOF
 
vagrant ssh -c /bin/sh <<EOF
     sudo apt-get update
+
     sudo yum update
     sudo apt-get -y install build-essential curl git man autoconf libtool python vim emacs
+
     sudo yum -y install @'development tools' emacs-nox
 
     git clone https://github.com/singularityware/singularity.git
 
     git clone https://github.com/singularityware/singularity.git
 
     cd singularity
 
     cd singularity

Revision as of 12:30, 12 May 2017

Singularity
Author Gregory M. Kurtzer and others
Website singularity.lbl.gov
Source GitHub
Category Container, Commandline utility
Help documentation
mailing list
PLoS paper


Singularity allows complex software to be run on the cluster, that would otherwise be difficult or impossible to install. Using singularity, you can generate a single "image" file in which you install all your software, and then you can copy that single image file and run it on the cluster. Additionally, singularity allows more directly comparisons of running software between different clusters, because you can use the exact same versions of software that may not be installed on the different clusters.

This guide will help you create your own singularity images.

Requirements:

  • Your computer with macOS, Windows, or a GNU/Linux operating system.
  • VirtualBox to create a virtual machine in which we will install singularity.
  • Vagrant( version 1.9 or later) to greatly simplify administration of our virtual machine.
  • At least 40 GB of disk space.

Getting started

To be able to create and edit a singularity image, you root administrator access on a machine. Therefore you cannot manage singularity containers directly on the cluster; you must install your own copy of singularity on your own computer. Singularity makes use of the Linux kernel to run the container, therefore you need a copy of GNU/Linux installed for which we will use a virtual machine. For best results, it also helps to use a similar Linux distribution to the environment we will finally be our singularity image. As our cluster uses RHEL 6.7, we will create our singularity image using CentOS which for our purposes is functionally identical to RHEL.

If you are using macOS, you can install singularity via homebrew as explained on the singularity page [1] but which we will repeat here for completeness:

# Only run these commands if you are using macOS!

# Install Brew if you do not have it installed already
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# The next commands will install Vagrant and the necessary bits
brew cask install virtualbox
brew cask install vagrant
brew cask install vagrant-manager

If you are using GNU/Linux, you can install virtualbox and vagrant through your package manager. You may need to log out and log in to your system again for your user account to be recognized as being in the vboxusers group.

Windows users can install virtualbox and vagrant directly from the main websites.

Now that we have the necessary tools, we can create our CentOS virtual machine in which we will install singularity:

# Create a working directory for the Vagrant configuration and
# generate a template Vagrantfile for "centos/7"
mkdir vm-singularity
cd vm-singularity
vagrant init centos/7
vagrant box add --provider virtualbox centos/7

# Build and start the Vagrant hosted VM
vagrant up --provider virtualbox

# Run the necessary commands within the VM to install Singularity
vagrant ssh -c /bin/sh <<EOF
    sudo yum update
    sudo yum -y install @'development tools' emacs-nox
    git clone https://github.com/singularityware/singularity.git
    cd singularity
    ./autogen.sh
    ./configure --prefix=/usr/local
    make
    sudo make install
EOF

# Singularity is installed in your Vagrant CentOS VM! Now you can
# use Singularity as you would normally by logging into the VM
# directly
vagrant ssh