Apptainer
For users that would like to run a containerized environment. You can utilize Apptainer on the CS cluster computers. Apptainer is a container platform. It allows you to create and run containers that package up pieces of software in a way that is portable and reproducible. You can build a container using Apptainer on your laptop, and then run it on many of the largest HPC clusters in the world, local university or company clusters, a single server, in the cloud, or on a workstation down the hall. Your container is a single file, and you don’t have to worry about how to install all the software you need on each different operating system.
Why use containers?
Containers are used to get software to run reliably across multiple computing platforms. They can also be used to simplify software installations across different groups or even members of the same group by packing all dependencies of an application within a single image. Since the entire user space portion of the Linux environment, including programs, custom configurations, and environment, are bundled into a single file, providing the following benefits:
- portability - the container file can be moved to different systems and run without modification.
- reproducibility - the container file contains all the software and dependencies needed to run the application.
- shareable - containers can be shared with collaborators, or published in repositories.
- usability - you can run software that is not installed on the system, or that is difficult to install.
- legacy software - you can run older software that is no longer supported on newer operating systems.
Getting and building Apptainer containers
Pre-built Docker and Apptainer containers are often available within scientific repositories and on GitHub.
Docker containers
Many docker containers can be run using Apptainer. You can pull a Docker container from Docker Hub and convert it to a Apptainer container using the apptainer pull or apptainer build commands.
Useful Apptainer Container repositories
Pre-built containers are also available in external repositories and can be loaded to the CSC using apptainer pull or apptainer build commands.
- Sylab’s Container Library
- Docker Hub
- Red Hat’s Quay (requires login)
- NVIDIA GPU Cloud
Creating your own Apptainer containers
Apptainer containers can be created and uploaded to the CS cluster. To do this you will need root access to a Linux system (free through Duke VCM, or use the OIT GitLab CI process.
Once your container is built you can move it to the cluster using Globus, scp, or sftp.
Using OIT GitLab CI
Users may also create their own Apptainer containers by using the OIT Gitlab CI process. Using GitLab CI, your build process for the Linux environment is automated through GitLab by providing a apptainer definition file and a .gitlab-ci.yml file. Using this process, the basic steps are:
- Create a project in GitLab. Each apptainer container should have its own project and your Container image will be named after the project.
- Create a apptainer.def) file in your project. You can create from scratch or start from a copy from a repository.
- Copy the .gitlab-ci.yml file from the sample project into your project. Once this file is added, every time you commit to your project, the GitLab Continuous Integration pipeline will be initiated and a apptainer image is created for your project.
- Pull your image down to the CS cluster from GitLab.
For more details see this: Sample Project
Running Apptainer on the CSC
Apptainer is available on the cluster and can be used as part of Slurm interactive or batch jobs.
Sample interactive session
In this session, user321 requests an interactive session through Slurm and executes a shell using the apptainer image for Tensorflow. Using apptainer in this way lets you interact with the environment like it is a virtual machine.
Sample batch session
The sample below illustrates how to use apptainer as part of a batch session.
Sample batch script(slurm_apptainer.sh):
Submitting the batch script: