Browse Source

Merge pull request #6 from alan-turing-institute/apptainer

Switch to Apptainer
Jim Madge 3 years ago
parent
commit
749a751355
4 changed files with 66 additions and 42 deletions
  1. 26 12
      .github/workflows/build.yaml
  2. 1 1
      .github/workflows/lint.yaml
  3. 22 12
      Vagrantfile
  4. 17 17
      base_containers/pytorch/pytorch_cu.def.template

+ 26 - 12
.github/workflows/build.yaml

@@ -1,7 +1,7 @@
 ---
 name: Build
 
-on: [push, pull_request]
+on: [push]
 
 jobs:
   build:
@@ -13,10 +13,18 @@ jobs:
         with:
           submodules: true
 
-      - name: Install singularity
+      - name: Setup Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: '^1.17.7'
+
+      - name: Install Apptainer dependencies
         run: |
+          # Apptainer installation instructions
+          # https://github.com/apptainer/apptainer/blob/main/INSTALL.md
+          #
+          # Install Apptainer dependencies
           sudo apt-get update
-          # Install singularity dependencies
           sudo apt-get install -y \
           build-essential \
           libssl-dev \
@@ -26,18 +34,24 @@ jobs:
           libseccomp-dev \
           wget \
           pkg-config \
-          git \
-          cryptsetup \
-          golang
-          # Get singularity release
-          export VERSION=3.8.0
-          wget https://github.com/hpcng/singularity/releases/download/v${VERSION}/singularity-${VERSION}.tar.gz
-          tar -xzf singularity-${VERSION}.tar.gz
-          # Build/install singularity
-          cd singularity-${VERSION}
+          cryptsetup
+          sudo apt-get clean
+
+      - name: Install Apptainer
+        run: |
+          #
+          # Get Apptainer release
+          export VERSION=1.0.0
+          wget https://github.com/apptainer/apptainer/releases/download/v${VERSION}/apptainer-${VERSION}.tar.gz
+          tar -xzf apptainer-${VERSION}.tar.gz
+          #
+          # Build/install Apptainer
+          cd apptainer-${VERSION}
           ./mconfig
           make -C builddir
           sudo make -C builddir install
+          cd ../
+          rm -r apptainer-${VERSION} apptainer-${VERSION}.tar.gz
 
       - name: Build pytorch GAN zoo
         working-directory: workflows/pytorch_GAN_zoo/

+ 1 - 1
.github/workflows/lint.yaml

@@ -1,7 +1,7 @@
 ---
 name: Lint
 
-on: [push, pull_request]
+on: [push]
 
 jobs:
   markdown_lint:

+ 22 - 12
Vagrantfile

@@ -1,7 +1,7 @@
 Vagrant.configure("2") do |config|
   config.vm.box = "generic/ubuntu2004"
 
-  config.vm.hostname = "singularity"
+  config.vm.hostname = "apptainer"
 
   config.vm.synced_folder "./", "/vagrant"
 
@@ -15,7 +15,10 @@ Vagrant.configure("2") do |config|
   end
 
   config.vm.provision "shell", inline: <<-SHELL
-    # Install singularity dependencies
+    # Apptainer installation instructions
+    # https://github.com/apptainer/apptainer/blob/main/INSTALL.md
+    #
+    # Install Apptainer dependencies
     apt-get update
     apt-get install -y \
     build-essential \
@@ -26,20 +29,27 @@ Vagrant.configure("2") do |config|
     libseccomp-dev \
     wget \
     pkg-config \
-    git \
-    cryptsetup \
-    golang
+    cryptsetup
     apt-get clean
-    # Get singularity release
-    export VERSION=3.8.0
-    wget https://github.com/hpcng/singularity/releases/download/v${VERSION}/singularity-${VERSION}.tar.gz
-    tar -xzf singularity-${VERSION}.tar.gz
-    # Build/install singularity
-    cd singularity-${VERSION}
+    #
+    # Install GO
+    export GOVERSION=1.17.7 OS=linux ARCH=amd64
+    wget -O go${GOVERSION}.${OS}-${ARCH}.tar.gz https://dl.google.com/go/go${GOVERSION}.${OS}-${ARCH}.tar.gz
+    tar -C /opt -xzf go${GOVERSION}.${OS}-${ARCH}.tar.gz
+    rm go${GOVERSION}.${OS}-${ARCH}.tar.gz
+    export PATH=$PATH:/opt/go/bin
+    #
+    # Get Apptainer release
+    export VERSION=1.0.0
+    wget https://github.com/apptainer/apptainer/releases/download/v${VERSION}/apptainer-${VERSION}.tar.gz
+    tar -xzf apptainer-${VERSION}.tar.gz
+    #
+    # Build/install Apptainer
+    cd apptainer-${VERSION}
     ./mconfig
     make -C builddir
     make -C builddir install
     cd ../
-    rm -r singularity-${VERSION} singularity-${VERSION}.tar.gz
+    rm -r apptainer-${VERSION} apptainer-${VERSION}.tar.gz
   SHELL
 end

+ 17 - 17
base_containers/pytorch/pytorch_cu.def.template

@@ -1,17 +1,17 @@
-BootStrap: library
-From: ubuntu:20.04
-
-%post
-    apt-get -y update
-
-    # Add universe repository (necessary for python3-pip)
-    apt-get -y install software-properties-common
-    add-apt-repository -y -u universe
-
-    # Install python packages
-    apt-get -y install python3 python3-pip
-
-    apt-get clean
-
-    # Install python dependencies
-    pip3 install --no-cache-dir torch==$torch_version torchvision==$torchvision_version torchaudio==$torchaudio_version -f $find_links
+Bootstrap: docker
+From: ubuntu:20.04
+
+%post
+    apt-get -y update
+
+    # Add universe repository (necessary for python3-pip)
+    apt-get -y install software-properties-common
+    add-apt-repository -y -u universe
+
+    # Install python packages
+    apt-get -y install python3 python3-pip
+
+    apt-get clean
+
+    # Install python dependencies
+    pip3 install --no-cache-dir torch==$torch_version torchvision==$torchvision_version torchaudio==$torchaudio_version -f $find_links