Singularity with WSL 2
This tutorial aims to install Singularity 4.0.2 on your Windows machine and is in most parts a direct extract from the INSTALL.md
of that release. This tutorial may be out of date, so check the INSTALL.md if you are using a different release.
Prerequisites
1. Activate WSL
In a Windows PowerShell, run following command as an administrator. You can get an administrator PowerShell by clicking the Windows icon, searching for „PowerShell“, and right-clicking the application and selecting „Run as administrator“.
wsl --install
WSL will then be available from your Start menu.
2. Install Dependencies
The first thing to do is to update your Linux distribution (the default WSL distribution is Ubuntu, if you change it this command may be different):
sudo bash -c 'apt update && apt upgrade -y' sudo apt install -y \ autoconf \ automake \ cryptsetup \ git \ libfuse-dev \ libglib2.0-dev \ libseccomp-dev \ libtool \ pkg-config \ runc \ squashfs-tools \ squashfs-tools-ng \ uidmap \ wget \ zlib1g-dev
Then install go. If you have go installed previously, be sure to remove /usr/local/go
first.
export VERSION=1.21.4 OS=linux ARCH=amd64 sudo rm -rf /usr/local/go wget -O /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz https://dl.google.com/go/go${VERSION}.${OS}-${ARCH}.tar.gz sudo tar -C /usr/local -xzf /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz # make go available for usage: echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc source ~/.bashrc
Install Singularity
All Singularity releases can be found here: https://github.com/sylabs/singularity/releases
We will continue with 4.0.2, so we will fetch and compile the code. After successful compilation it will be installed on your system:
wget -O /tmp/singularity-ce-4.0.2.tar.gz https://github.com/sylabs/singularity/releases/download/v4.0.2/singularity-ce-4.0.2.tar.gz tar -C /tmp -xvf /tmp/singularity-ce-4.0.2.tar.gz cd /tmp/singularity-ce-4.0.2 make -C builddir && sudo make -C builddir install
Your Singularity installation can now be tested via
singularity --version
If everything went well, the output should be
singularity-ce version 4.0.2