Background
What is Singularity?*
"Singularity enables users to have full control of their environment. Singularity containers can be used to package entire scientific workflows, software and libraries, and even data. This means that you dont have to ask your cluster admin to install anything for you - you can put it in a Singularity container and run."
There are numerous good tutorials on how to install and run Singularity on Linux, OS X, or Windows so we won't go into much detail on that process here. In this tutorial you will learn how to run Singularity on Comet. First we will review how to access a compute node on Comet and provide a simple example to help get you started. There are numerous tutorial on how to get started with Singularity, but there are some details specific to running Singularity on Comet which are not covered in those tutorials. This tutorial assumes you already have an account on Comet. You will also need access to a basic set of example files to get started. SDSC hosts a Github repository containing a Hello world! example which you may clone with the following command:
> git clone https://github.com/hpcdevops/singularity-hello-world.git
Below is a typical list of commands you would need to issue in order to implement a functional Python installation for scientific research:
COMMAND=apt-get -y install libx11-dev COMMAND=apt-get install build-essential python-libdev COMMAND=apt-get install build-essential openmpi-dev COMMAND=apt-get install cmakeCOMMAND=apt-get install g++ COMMAND=apt-get install git-lfs COMMAND=apt-get install libXss.so.1COMMAND=apt-get install libgdal1-dev libproj-dev COMMAND=apt-get install libjsoncpp-dev libjsoncpp0 COMMAND=apt-get install libmpich-dev --userCOMMAND=apt-get install libpthread-stubs0 libpthread-stubs0-dev libx11-dev libx11-d COMMAND=apt-get install libudev0:i386COMMAND=apt-get install numpy COMMAND=apt-get install python-matplotlib COMMAND=apt-get install python3
Singularity allows you to avoid this time-consuming series of steps by packaging these commands in a re-usable and editable script, allowing you to quickly, easily, and repeatedly implement a custom container designed specifically for your analytical needs.
The diagram below compares a VM vs. Docker vs. Singularity.
Next, let's get some hands-on experience with Singularity. The following tutorial includes links to asciinema video tutorials created by SDSC HPC Systems Manager, Trevor Cooper (Thanks, Trevor!) which allow you to see the console interactivity and output in detail. Look for the video icon like the one shown to the right corresponding to the task you are currently working on.
First we download and upack the source using the following commands (assuming your user name is 'test_user' and you are working on your local computer with super user privileges):
[test_user@localhost ~]$ wget https://github.com/singularityware/singularity/releases/download/2.5.1/singularity-2.5.1.tar.gz tar -zxf singularity-2.5.1.tar.gz
If the file is successfully extracted, you should be able to view the results:
Next we configure and build the package. To configure, enter the following command (we'll leave out the command prompts):
To build, issue the following command:
This may take several seconds depending on your computer.
To complete the installation enter:
You should be prompted to enter your admin password.
Once the installation is completed, you can check to see if it succeeded in a few different ways:
You can also run a selftest with the following command:
The output should look something like:
The process of building a Singularity container consists of a few distinct steps as follows.
We will go through each of these steps in detail.
We recommend building containers using the same version of Singularity, 2.5.1, as exists on Comet. This is a 2 step process.
Step 1: run the script below to remove your existing Singularity:
#!/bin/bash## A cleanup script to remove Singularity
sudo rm -rf /usr/local/libexec/singularitysudo rm -rf /usr/local/etc/singularitysudo rm -rf /usr/local/include/singularitysudo rm -rf /usr/local/lib/singularitysudo rm -rf /usr/local/var/lib/singularity/sudo rm /usr/local/bin/singularitysudo rm /usr/local/bin/run-singularitysudo rm /usr/local/etc/bash_completion.d/singularitysudo rm /usr/local/man/man1/singularity.1
Step 2: run the following script to install Singularity 2.5.1:
#!/bin/bash## A build script for Singularity (http://singularity.lbl.gov/)
declare -r SINGULARITY_NAME='singularity'declare -r SINGULARITY_VERSION='2.5.1'declare -r SINGULARITY_PREFIX='/usr/local'declare -r SINGULARITY_CONFIG_DIR='/etc'
sudo apt updatesudo apt install python dh-autoreconf build-essential debootstrap
cd ../tar -xzvf "${PWD}/tarballs/${SINGULARITY_NAME}-${SINGULARITY_VERSION}.tar.gz"cd "${SINGULARITY_NAME}-${SINGULARITY_VERSION}"./configure --prefix="${SINGULARITY_PREFIX}" --sysconfdir="${SINGULARITY_CONFIG_DIR}"makesudo make install
To create an empty Singularity container, you simply issue the following command:
This will create a CentOS 7 container with a default size of ~805 Mb. Depending on what additional configurations you plan to make to the container, this size may or may not be big enough. To specify a particular size, such as ~4 Gb, include the -s parameter, as shown in the following command:
To view the resulting image in a directory listing, enter the following:
Next, we will import a Docker image into our empty Singularity container:
Once the container actually contains a CentOS 7 installation, you can shell into it with the following:
Once you enter the container you should see a different command prompt. At this new prompt, try typing:
Your user id should be identical to your user id outside the container. However, the operating system will probably be different. Try issuing the following command from inside the container to see what the OS version is:
Next, lets trying writing into the container (as root):
You should be prompted for your password, and then you should see something like the following:
Next, lets create a script within the container so we can use it to test the ability of the container to execute shell scripts:
The above command assumes you know the vi editor. Enter the following text into the script, save it, and quit the vi editor:
You may need to change the permissions on the script so it can be executable:
Try running the script manually:
The output should be:
Bootstrapping a Singularity container allows you to use what is called a definitions file so you can reproduce the resulting container configurations on demand.
Lets say you want to create a container with Ubuntu, but you may want to create variations on the configurations without having to repeat a long list of commands manually. First, we need our definitions file. Below is the contents of a definitions file which should suffice for our purposes.
%runscriptexec echo The runscript is the containers default runtime command!
%files/home/testuser/ubuntu.def /data/ubuntu.def
%labelsAUTHOR testuser@sdsc.edu
%postapt-get update && apt-get -y install python3 git wgetmkdir /dataecho The post section is where you can install and configure your container.
To bootstrap your container, first we need to create an empty container.
Now, we simply need to issue the following command to configure our container with Ubuntu:
This may take a while to complete. In principle, you can accomplish the same result by manually issuing each of the commands contained in the script file, but why do that when you can use bootstrapping to save time and avoid errors.
If all goes according to plan, you should then be able to shell into your new Ubuntu container.
Of course, the purpose of this tutorial is to enable you to use the San Diego Supercomputer Centers Comet supercomputer to run your jobs. This assumes you have an account on Comet already. If you do not have an account on Comet and you feel you can justify the need for such an account (i.e. your research is limited by the limited compute power you have in your government-funded research lab), you can request a Startup Allocation through the XSEDE User Portal:
https://portal.xsede.org/allocations-overview#types-trial
You may create a free account on the XUP if you do not already have one and then proceed to submit an allocation request at the above link.
[NOTE: SDSC provides a Comet User Guide ( http://www.sdsc.edu/support/user_guides/comet.html ) to help get you started with Comet. Learn more about The San Diego Supercomputer Center at http://www.sdsc.edu .]
This tutorial walks you through the following four steps towards running your first Singularity container on Comet:
Once you have created your container on your local system, you will need to transfer it to Comet. There are multiple ways to do this and it can take a varying amount of time depending on its size and your network connection speeds.
To do this, we will use scp (secure copy). If you have a Globus account and your containers are more than 4 Gb you will probably want to use that file transfer method instead of scp.
Browse to the directory containing the container. Copy the container to your scratch directory on Comet. By issuing the following command:
The container is ~805 Mb so it should not take too long, hopefully.
Once the file is transferred, login to Comet (assuming your Comet user is named 'test_user'):
Navigate to your scratch directory on Comet, which should be something like:
Next, you should submit a request for an interactive session on one of Comets compute, debug, or shared nodes.
Once your request is approved your command prompt should reflect the new node id.
Before you can run your container you will need to load the Singularity module (if you are unfamiliar with modules on Comet, you may want to review the Comet User Guide). The command to load Singularity on Comet is:
You may issue the above command from any directory on Comet. Recall that we added a hello_world.sh script to our centos7.img container. Lets try executing that script with the following command:
If all goes well, you should see Hello, World! in the console output. You might also see some warnings pertaining to non-existent bind points. You can resolve this by adding some additional lines to your definitions file before you build your container. We did not do that for this tutorial, but you would use a command like the following in your definitions file:
You will find additional examples located in the following locations on Comet:
and
It is best to avoid working on Comets login nodes since they can become a performance bottleneck not only for you but for all other users. You should rather allocate resources specific for computationally-intensive jobs. To allocate a compute node for your user on Comet, issue the following command:
This allocation requests a single node (-N 1) for a total time of 10 minutes (-t 00:10:00). Once your request has been approved, your computer node name should be displayed, e.g. comet-17-12.
Now you may login to this node:
Notice that the command prompt has now changed to reflect the fact that you are on a compute node and not a login node.
Next, load the Singularity module, shell into the container, and execute the hello_world.sh script:
If all goes well, you should see Hello, World! in the console output.
Of course, most users simply want to submit their jobs to the Comet queue and let it run to completion and go on to other things while waiting. Slurm is the job manager for Comet.
Below is a job script (which we will name singularity_mvapich2_hellow.run) which will submit your Singularity container to the Comet queue and run a program, hellow.c (written in C using MPI and provided as part of the examples with the mvapich2 default installation).
#!/bin/bash #SBATCH --job-name="singularity_mvapich2_hellow" #SBATCH --output="singularity_mvapich2_hellow.%j.out" #SBATCH --error="singularity_mvapich2_hellow.%j.err" #SBATCH --nodes=2 #SBATCH --ntasks-per-node=24 #SBATCH --time=00:10:00 #SBATCH --export=all module load mvapich2_ib singularity
CONTAINER=/oasis/scratch/comet/$USER/temp_project/singularity/centos7-mvapich2.img
mpirun singularity exec ${CONTAINER} /usr/bin/hellow
The above script requests 2 nodes and 24 tasks per node with a wall time of 10 minutes. Notice that two modules are loaded (see the line beginning with module), one for Singularity and one for MPI. An environment variable CONTAINER is also defined to make it a little easier to manage long reusable text strings such as file paths.
You may need to add a line specifying with allocation to be used for this job. When you are ready to submit the job to the Comet queue, issue the following command:
To view the status of your job in the Comet queue, issue the following:
When the job is complete, view the output which should be written to the output file singularity_mvapich2_hellow.%j.out where %j is the job ID (lets say the job ID is 1000001):
See the original post:
- Singularity Future Technology Ltd (SGLY) is up 43.55% Tuesday In Premarket Trading - InvestorsObserver - March 18th, 2024 [March 18th, 2024]
- This Week's Awesome Tech Stories From Around the Web (Through March 16) - Singularity Hub - March 18th, 2024 [March 18th, 2024]
- Palia reaches over 3m players in six months thanks to "invaluable" Switch partnership - GamesIndustry.biz - March 18th, 2024 [March 18th, 2024]
- Beyond the Singularity: Exploring the Fusion of AI and Art - Hong Kong Standard - March 18th, 2024 [March 18th, 2024]
- Your Comprehensive Guide to Telos Staking Success | by Pizza Singularity Sapphire | Feb, 2024 - Medium - February 20th, 2024 [February 20th, 2024]
- BTS' Kim Taehyung's 'Singularity' Performance Featured in Harvard Professor's Book - BNN Breaking - February 20th, 2024 [February 20th, 2024]
- Title: Understanding the Singularity: Unveiling the Future of Humanity - Medium - December 12th, 2023 [December 12th, 2023]
- What happens at the center of a black hole? - Astronomy Magazine - December 12th, 2023 [December 12th, 2023]
- IBM Is Planning to Build Its First Fault-Tolerant Quantum Computer by 2029 - Singularity Hub - December 12th, 2023 [December 12th, 2023]
- 22 Laws of Singularity And How You Can Apply Them To Live A Better Life - Medium - December 12th, 2023 [December 12th, 2023]
- Singularity: Here's When Humanity Will Reach It, New Data Shows - March 31st, 2023 [March 31st, 2023]
- sentinelOne expands singularity marketplace with new SOAR, insider threat, training, and prioritization integrations - ZAWYA - March 31st, 2023 [March 31st, 2023]
- Reaching the Singularity May be Humanitys Greatest and Last ... - March 4th, 2023 [March 4th, 2023]
- Singularity: Explain It to Me Like I'm 5-Years-Old - Futurism - March 4th, 2023 [March 4th, 2023]
- SINGULARITY FUTURE TECHNOLOGY LTD. : Notice of Delisting or Failure to Satisfy a Continued Listing Rule or Standard; Transfer of Listing, Change in... - March 4th, 2023 [March 4th, 2023]
- Apple co-founder Steve Wozniak on Artificial Intelligence: Not worried about The Singularity, well still be in control - MacDailyNews - February 12th, 2023 [February 12th, 2023]
- Cauchy principal value - Wikipedia - January 4th, 2023 [January 4th, 2023]
- Singularity Future Technology Ltd. (SGLY) Stockholder Notice: Robbins LLP Reminds Investors of the Class Action Against Singularity Future Technology... - December 14th, 2022 [December 14th, 2022]
- ROSEN, A LEADING LAW FIRM, Encourages Singularity Future Technology Ltd. f/k/a Sino-Global Shipping America Ltd. Investors to Secure Counsel Before... - December 12th, 2022 [December 12th, 2022]
- Singularity (mathematics) - Wikipedia - November 23rd, 2022 [November 23rd, 2022]
- GitHub: Where the world builds software GitHub - November 21st, 2022 [November 21st, 2022]
- Review: The Singularities, by John Banville - The New York Times - October 25th, 2022 [October 25th, 2022]
- We need to manage AI better as we are approaching the Creative Singularity - RedShark News - October 15th, 2022 [October 15th, 2022]
- This Week's Awesome Tech Stories From Around the Web (Through October 15) - Singularity Hub - October 15th, 2022 [October 15th, 2022]
- Ferguson: A second helping of QB play from Thanksgiving weekend - CFL.ca - October 15th, 2022 [October 15th, 2022]
- Kanimozhi slams Union govt over conducting CGL exams in only Hindi and English - The News Minute - October 15th, 2022 [October 15th, 2022]
- New Bayonetta 3 Trailer Reveals An In-Universe Singularity, And Lots Of Witches - Gameranx - October 13th, 2022 [October 13th, 2022]
- Singularity Future Technology Announces Receipt of Nasdaq Notice of Delisting and Intention to Request Hearing - Yahoo Finance - October 13th, 2022 [October 13th, 2022]
- Six Recent Discoveries That Have Changed How We Think About Human Origins - Singularity Hub - October 13th, 2022 [October 13th, 2022]
- This AI Uses a Scan of Your Retina to Predict Your Risk of Heart Disease - Singularity Hub - October 13th, 2022 [October 13th, 2022]
- The Moon May Have Formed Just Hours After Earth Collided With a Protoplanet - Singularity Hub - October 13th, 2022 [October 13th, 2022]
- UK HealthCare hosting 2 nationally esteemed guests for 60th anniversary symposium - UKNow - October 13th, 2022 [October 13th, 2022]
- Why Transcend Fund believes the opportunity for game investments is only getting bigger - VentureBeat - October 13th, 2022 [October 13th, 2022]
- Austin Powers References in This Fool, Ramy, Bros - Vulture - October 13th, 2022 [October 13th, 2022]
- Bayonetta 3 Everything You Need to Know About this Bewitching Beat em Up - Wccftech - October 8th, 2022 [October 8th, 2022]
- Longtermism: The Future Is VastWhat Does This Mean for Our Own Life? - Singularity Hub - October 8th, 2022 [October 8th, 2022]
- Ohio creates elections integrity office while voter fraud is already 'exceedingly rare' - ideastream - October 8th, 2022 [October 8th, 2022]
- Elon Musk Warns of World War III - TheStreet - October 8th, 2022 [October 8th, 2022]
- Durga reminds us of our collective obligations - Daily Pioneer - October 8th, 2022 [October 8th, 2022]
- Glitch in the algorithm - The Bucknellian - October 8th, 2022 [October 8th, 2022]
- As the Robot Fry Cook Takes Over the Kitchen - Walter Bradley Center for Natural and Artificial Intelligence - October 8th, 2022 [October 8th, 2022]
- The Singularity Image Format (SIF) Selected as a Finalist in the HPCwire Readers' Choice Awards - PR Web - October 6th, 2022 [October 6th, 2022]
- The Singularity Image Format (SIF) Selected as a Finalist in the HPCwire Readers' Choice Awards - Benzinga - October 6th, 2022 [October 6th, 2022]
- The Singularity of the Dual Mandate - Federal Reserve Bank of San Francisco - October 6th, 2022 [October 6th, 2022]
- What Is the Quirk Singularity Doomsday Theory in My Hero Academia? Explained - Twinfinite - October 6th, 2022 [October 6th, 2022]
- Introduction to week 4 of Tekedia Mini-MBA: Exponential Technologies and Singularity - Tekedia - October 6th, 2022 [October 6th, 2022]
- A $500 Million International Project Will Create the Most Detailed Map of the Brain Ever - Singularity Hub - October 6th, 2022 [October 6th, 2022]
- There Are Cheaper, More Sustainable Ways Than Desalination to Meet Our Water Needs - Singularity Hub - October 6th, 2022 [October 6th, 2022]
- #3DStartup: Unlimited Tomorrow and its 3D Printed Bionic Prosthetic Arm - 3Dnatives - October 6th, 2022 [October 6th, 2022]
- First As Parody, Then As Free Speech: The Onion Goes To The Supreme Court. It's About As Awesome As You'd Suspect. - Above the Law - October 6th, 2022 [October 6th, 2022]
- 10 Hot Cyber Threat Intelligence Tools And Services In 2022 - CRN - October 6th, 2022 [October 6th, 2022]
- Nintendo comes out strong with its offering of upcoming titles - The UML Connector - October 6th, 2022 [October 6th, 2022]
- The metaverses evolutionary roots could aid its success | Mint - Mint - October 6th, 2022 [October 6th, 2022]
- The Tech That Will Push VR to the Limits of the Human Eye - Singularity Hub - September 27th, 2022 [September 27th, 2022]
- Super-Earths Are Bigger and More Habitable Than Earth, and Astronomers Are Discovering More of the Billions They Think Are Out There - Singularity Hub - September 27th, 2022 [September 27th, 2022]
- Scientists Have Long Dreamed of a Memory Prosthesis. The First Human Trials Look Promising - Singularity Hub - September 27th, 2022 [September 27th, 2022]
- NASA's DART Spacecraft Will Smack an Asteroid at 14,000 MPH Todayand You Can Watch - Singularity Hub - September 27th, 2022 [September 27th, 2022]
- Why You Should Read This: 'The Gold Coast' - Alta Magazine - September 27th, 2022 [September 27th, 2022]
- The Multitude of Stromae - Mail and Guardian - September 27th, 2022 [September 27th, 2022]
- Warhammer 40,000: Space Marine is Getting a Location-based VR Experience Next Year - Road to VR - September 27th, 2022 [September 27th, 2022]
- What the pandemic taught us about teaching (On the Other Hand) - Montclair Local - September 27th, 2022 [September 27th, 2022]
- Where to get the Boom Sniper in Fortnite Chapter 3 Season 4 - The Nerd Stash - September 27th, 2022 [September 27th, 2022]
- Machine learning has predicted the winners of the Worlds - CyclingTips - September 27th, 2022 [September 27th, 2022]
- Vaonis Vespera Review: Easy To Use But with Underwhelming Results - PetaPixel - September 27th, 2022 [September 27th, 2022]
- The biggest problem with gravity and quantum physics - Big Think - September 27th, 2022 [September 27th, 2022]
- V gets inked on his butt cheek? BTS star spills the details about his friendship tattoo - Zoom TV - September 27th, 2022 [September 27th, 2022]
- Robots & Humans: Are we heading towards Singularity? - INDIAai - September 20th, 2022 [September 20th, 2022]
- This Week's Awesome Tech Stories From Around the Web (Through September 17) - Singularity Hub - September 20th, 2022 [September 20th, 2022]
- A Swedish Company Wants to Transform Offshore Wind With Vertical-Axis Turbines - Singularity Hub - September 20th, 2022 [September 20th, 2022]
- Decarbonizing the Energy Sector by 2050 Could Save the World $12 Trillion - Singularity Hub - September 20th, 2022 [September 20th, 2022]
- This Sleek Solar Car Goes 600 Miles on a Charge and Is Gearing Up for Production - Singularity Hub - September 20th, 2022 [September 20th, 2022]
- Meta Built an AI That Can Guess the Words You're Hearing by Decoding Your Brainwaves - Singularity Hub - September 20th, 2022 [September 20th, 2022]
- Gory Throwback FPS 'Prodeus' Exits Early Access This Thursday, Launching for PC and Consoles [Trailer] - Bloody Disgusting - September 20th, 2022 [September 20th, 2022]
- Meet the New Vespera Telescope From Vaonis - Universe Today - September 20th, 2022 [September 20th, 2022]
- Of God and Machines - The Atlantic - September 20th, 2022 [September 20th, 2022]
- Humans Destroyed Forests for Thousands of Years. We Can Become the First Generation to Expand Them - Singularity Hub - September 20th, 2022 [September 20th, 2022]
- Intel Core i9-13900K beats the 12900K by +10% in CPU-bound games - KitGuru - September 20th, 2022 [September 20th, 2022]
- INVESTIGATION ALERT: The Schall Law Firm Encourages Investors in Singularity Future Technology Ltd. with Losses of $100000 to Contact the Firm -... - August 15th, 2022 [August 15th, 2022]
- How To Open Singularity Rock in Tower of Fantasy - Attack of the Fanboy - August 15th, 2022 [August 15th, 2022]
- Intel i9-13900K Tested in Ashes Of The Singularity, Offers Neglible Increments in Performance - Appuals - August 15th, 2022 [August 15th, 2022]