Installing SingularityCE on macOS with Apple Silicon, using UTM

By Staff

In this post, we will cover how to install SingularityCE on a macOS machine running on Apple Silicon (M1 /M2 and their variants). We will do this using the free and open-source UTM, which will allow us to run an ARM64 Linux virtual machine on macOS using native virtualization.

Downloading & Installing UTM

In your browser, go to mac.getutm.app, and click on the Download button.
Mount the downloaded UTM.dmg disk-image and drag the UTM app to the Applications folder.
Next, launch the UTM app from your Mac’s local Applications folder. (Depending on your Mac’s security settings, you may get a confirmation dialog when you launch UTM for the first time. If such a dialog appears, choose Open.)
This should bring you to the main UTM application window, which looks like this:

Installing an ARM64 Linux VM

From the main UTM application window, choose Browse UTM Gallery to open the page on the UTM website containing pre-built guest operating-system images. For the purposes of this demo, we will use the pre-built Debian 11 (Xfce) image.
Click on the screenshot for the Debian 11 (Xfce) image to open its dedicated page.
From here, select the Open in UTM option – not the Download option – to open this image directly in the UTM app. (You may get a confirmation dialog asking you to allow the UTM website to link back to the UTM app in this fashion. Choose the Allow option.) This should automatically initiate a download of the Debian 11 (Xfce) image from within the UTM app. You’ll be able to see the download progress and estimated time remaining in the Pending section of the UTM app’s sidebar.
Once the download is complete, you will see the downloaded virtual machine in UTM’s sidebar, in this case preceded by the Debian logo:

Increasing the VM’s memory allocation

IMPORTANT:
To ensure that SingularityCE has sufficient resources to run in the virtual machine, it is preferable to adjust the memory settings of the virtual machine before launching it.

The Debian 11 (Xfce) image, as downloaded from the UTM Gallery website, comes with a setting of 1024MB(=1GB) of RAM. Let’s change that to 4096MB(=4GB). Click once on the name of the virtual machine (“Debian 11 (Xfce)”), NOT on the ‘play’ icon that’s to its right.

This will bring you to the VM overview screen. From here, click on the “sliders” icon in the top-right corner, which will bring you to the VM settings view. Click on System in the left hand sidebar, and drag the memory slider until the amount is set to 4096 MB, as shown here:
Finally, click the Save button at the bottom-right to apply these changes.

Booting up the Linux VM for the first time

You can now click on the ‘play’ (▶️) icon to launch the virtual machine. Once it’s done booting up, you will be greeted with a login dialog. If you downloaded this Debian image from the UTM Gallery as suggested above, the login credentials should be:

  • username: debian
  • password: debian
(You can, and probably should, change the password after your first login.)

Installing the prerequisites

Once you have logged in, open a Terminal:
NOTE: The instructions from this point on follow the Quick Installation Steps in the SingularityCE User Guide, and can all be carried out from within your terminal window. Install the prerequisites for building SingularityCE, as follows:
sudo apt-get update && \
   sudo apt-get install -y \
      wget \
      build-essential \
      libseccomp-dev \
      libglib2.0-dev \
      pkg-config \
      squashfs-tools \
      cryptsetup \
      runc \
      curl
This requires sudo, and will therefore ask you for the debian user’s password (which, unless you’ve already changed the initial password, is also debian).

Installing the latest Go release

The next step is to download & install the latest Go release.
NOTE: The release number 1.20.2, used in the snippets below, corresponds to the latest Go release at the time of this writing. Check go.dev/dl/ for the latest release number, and replace 1.20.2 below with that number.
curl -LO https://go.dev/dl/go1.20.2.linux-arm64.tar.gz
sudo rm -rf /usr/local/go && \
   sudo tar -C /usr/local -xzf go1.20.2.linux-arm64.tar.gz
Next, ensure the Go binaries are present in bash’s PATH, by running:
echo 'export PATH=/usr/local/go/bin:$PATH' >> ~/.bashrc && \
  source ~/.bashrc
The latest Go release should be available on your Debian system. Check this by running go version, whose output should look something like this:
$ go version
go version go1.20.2 linux/arm64

Installing SingularityCE

Now it’s time to install SingularityCE itself!
NOTE: The release number v3.11.0, used in the snippets below, corresponds to the latest SingularityCE release at the time of this writing. Check github.com/sylabs/singularity/releases for the latest release number, and replace v3.11.0 below with that number.
Download & unpack the source tarball for the latest release of SingularityCE:
curl -LO https://github.com/sylabs/singularity/releases/download/v3.11.0/singularity-ce-3.11.0.tar.gz && \
   tar -xf singularity-ce-3.11.0.tar.gz
Go into the newly-created subdirectory, and run the build steps for SingularityCE:
cd singularity-ce-3.11.0
./mconfig && \
    make -C builddir && \
    sudo make -C builddir install
You can validate that Singularity has been successfully compiled & installed by running singularity –version, whose output should look something like this:
$ singularity --version
singularity-ce version 3.11.0

Creating & running your first container

To make sure our installation of SingularityCE was successful, let’s create & run our first container. We can do this as follows:
singularity run library://lolcow
This should download the latest lolcow container image from the Singularity Container Library and run it. The output should look something like this:
$ singularity run library://lolcow
INFO:    Downloading library image
86.9MiB / 86.9MiB [=========================================] 100 % 7.5 MiB/s 0s
 ______________________________
< Fri Mar 10 09:46:31 PST 2023 >
 ------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
Congratulations! You have successfully installed SingularityCE on a Linux virtual-machine running on an Apple Silicon Mac!

Join Our Mailing List

Recent Posts

Related Posts

Remote Building with OCI Registries

This blog post will demonstrate how to use a definition file in a remote build that references an Open Container Initiative (OCI) image stored in Singularity Enterprise and Singularity Container Services.First, create an account in Singularity Container Service. To do...

read more