Singularity gives us a way to package up an entire software stack in a way that is portable across different machines. The idea is to build an image that should be:
- Reproducible
- Sharable
- Portable across machines
We use a virtual box that has everything needed to build the singularity image pre-installed. This works on linux, mac, and windows. On linux, you can avoid this step and use singularity directly, either by installing the appropriate package or by building from source.
- Install VirtualBox
- Install Vagrant
vagrant plugin install vagrant-disksize
Run vagrant up
to boot up the virutal machine.
Run vagrant ssh
to connect to the virtual machine. Press Ctrl-D
to exit.
Run vagrant halt
to stop the virtual machine. If you want to reclaim the space,
run vagrant destroy
to remove the image from your system. (The vagrant images
can be quite large.)
Edit meld.def
as needed. The main section that might need to updated is %post
,
which is the series of steps that are used to install meld and all dependencies
into the image.
The main lines that might need to be changed are the ones that download specific versions of openmm and meld from github. The format of the github urls is as follows.
- Tagged version
https://github.com/openmm/openmm/archive/7.6.0.tar.gz
- This will download the version tagged with
7.6.0
- The resulting directory will be
openmm-7.6.0
- This will download the version tagged with
- Specific branch
https://github.com/openmm/openmm/archive/master.tar.gz
- This will download the branch
master
- The resulting directory will be
openmm-master
- This will download the branch
- Specific hash
https://github.com/openmm/openmm/archive/ed9df87.tar.gz
- This will download the specific commite with has
ed9df87
- The resulting directory will be
openmm-ed9df87
- This will download the specific commite with has
Connect to the virtual machine:
vagrant up
vagrant ssh
cd /vagrant
The /vagrant
directory is a pass-through directory. Files in this directory
are accessible in both the virtual machine and the host system.
sudo singularity build image_name.sif meld.def
It's not helpful to have dozens of images all named meld.sif
. The following
naming scheme is strongly recommmended:
meld_MELDVER_omm_OMMVER
where OMMVER
is the openmm version and can either be a tagged release, like
7.6.0
, or a speficic hash, like ed9df87
. MELDVER
is the same thing, but
for meld. Do not use a branch name, like master
, as this will change as
the source tree is updated -- use a specific hash instead.
vagrant halt
- (Optional)
vagrant destroy
Copy the image to the system you intend to use (e.g. cedar or glados). It is recommended to store the images in a standard location, like in your home directory or project space.
To use interactively:
singularity shell BIND_COMMANDS IMAGE_PATH
To use in a job script:
srun singularity BIND_COMMANDS IMAGE_PATH COMMAND_TO_RUN
Bind commands allow for the host file system to show up inside of the singularity image:
- glados: bind commands can be left blank, as
/home
is mounted by default - cedar: -B /home -B /project -B /scratch
For COMMAND_TO_RUN, note that the images use the python3
command, rather
than python
.