|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +################################################################ |
| 6 | +# |
| 7 | +# Flux, Singularity, and EFA |
| 8 | +# |
| 9 | + |
| 10 | +/usr/bin/cloud-init status --wait |
| 11 | + |
| 12 | +export DEBIAN_FRONTEND=noninteractive |
| 13 | +sudo apt-get update && \ |
| 14 | + sudo apt-get install -y apt-transport-https ca-certificates curl jq apt-utils wget \ |
| 15 | + libelf-dev libpcap-dev libbfd-dev binutils-dev build-essential make \ |
| 16 | + linux-tools-common linux-tools-$(uname -r) \ |
| 17 | + python3-pip git net-tools |
| 18 | + |
| 19 | +# cmake is needed for flux-sched, and make sure to choose arm or x86 |
| 20 | +export CMAKE=3.23.1 |
| 21 | +export ARCH=x86_64 |
| 22 | +export ORAS_ARCH=amd64 |
| 23 | + |
| 24 | +curl -s -L https://github.com/Kitware/CMake/releases/download/v$CMAKE/cmake-$CMAKE-linux-$ARCH.sh > cmake.sh && \ |
| 25 | + sudo sh cmake.sh --prefix=/usr/local --skip-license && \ |
| 26 | + sudo apt-get install -y man flex ssh sudo vim luarocks munge lcov ccache lua5.4 \ |
| 27 | + valgrind build-essential pkg-config autotools-dev libtool \ |
| 28 | + libffi-dev autoconf automake make clang clang-tidy \ |
| 29 | + gcc g++ libpam-dev apt-utils lua-posix \ |
| 30 | + libsodium-dev libzmq3-dev libczmq-dev libjansson-dev libmunge-dev \ |
| 31 | + libncursesw5-dev liblua5.4-dev liblz4-dev libsqlite3-dev uuid-dev \ |
| 32 | + libhwloc-dev libs3-dev libevent-dev libarchive-dev \ |
| 33 | + libboost-graph-dev libboost-system-dev libboost-filesystem-dev \ |
| 34 | + libboost-regex-dev libyaml-cpp-dev libedit-dev uidmap dbus-user-session python3-cffi |
| 35 | + |
| 36 | +# Prepare lua rocks (does it really rock?) |
| 37 | +sudo locale-gen en_US.UTF-8 |
| 38 | + |
| 39 | +# This is needed if you intend to use EFA (HPC instance type) |
| 40 | +# Install EFA alone without AWS OPEN_MPI |
| 41 | +# At the time of running this, latest was 1.32.0 |
| 42 | +export EFA_VERSION=latest |
| 43 | +mkdir /tmp/efa |
| 44 | +cd /tmp/efa |
| 45 | +curl -O https://s3-us-west-2.amazonaws.com/aws-efa-installer/aws-efa-installer-${EFA_VERSION}.tar.gz |
| 46 | +tar -xf aws-efa-installer-${EFA_VERSION}.tar.gz |
| 47 | +cd aws-efa-installer |
| 48 | +sudo ./efa_installer.sh -y |
| 49 | + |
| 50 | +# - /var/lib/dkms/efa/2.10.0/6.5.0-1022-aws/aarch64/module/efa.ko |
| 51 | +# Processing triggers for man-db (2.10.2-1) ... |
| 52 | +# Processing triggers for libc-bin (2.35-0ubuntu3.8) ... |
| 53 | +# NEEDRESTART-VER: 3.5 |
| 54 | +# NEEDRESTART-KCUR: 6.5.0-1022-aws |
| 55 | +# NEEDRESTART-KEXP: 6.5.0-1022-aws |
| 56 | +# NEEDRESTART-KSTA: 1 |
| 57 | +# NEEDRESTART-SVC: dbus.service |
| 58 | +# NEEDRESTART-SVC: networkd-dispatcher.service |
| 59 | +# NEEDRESTART-SVC: systemd-logind.service |
| 60 | +# NEEDRESTART-SVC: unattended-upgrades.service |
| 61 | +# NEEDRESTART-SVC: [email protected] |
| 62 | +# Updating boot ramdisk |
| 63 | +# update-initramfs: Generating /boot/initrd.img-6.5.0-1022-aws |
| 64 | +# System running in EFI mode, skipping. |
| 65 | +# libfabric1-aws is verified to install /opt/amazon/efa/lib/libfabric.so |
| 66 | +# openmpi40-aws is verified to install /opt/amazon/openmpi/lib/libmpi.so |
| 67 | +# openmpi50-aws is verified to install /opt/amazon/openmpi5/lib/libmpi.so |
| 68 | +# efa-profile is verified to install /etc/ld.so.conf.d/000_efa.conf |
| 69 | +# efa-profile is verified to install /etc/profile.d/zippy_efa.sh |
| 70 | +# Reloading EFA kernel module |
| 71 | +# EFA device not detected, skipping test. |
| 72 | +# =================================================== |
| 73 | +# EFA installation complete. |
| 74 | +# - Please logout/login to complete the installation. |
| 75 | +# - Libfabric was installed in /opt/amazon/efa |
| 76 | +# - Open MPI 4 was installed in /opt/amazon/openmpi |
| 77 | +# - Open MPI 5 was installed in /opt/amazon/openmpi5 |
| 78 | +# =================================================== |
| 79 | +# fi_info -p efa -t FI_EP_RDM |
| 80 | +# Disable ptrace |
| 81 | +# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa-start.html |
| 82 | +sudo sysctl -w kernel.yama.ptrace_scope=0 |
| 83 | + |
| 84 | +################################################################ |
| 85 | +## Install Flux and dependencies |
| 86 | +# |
| 87 | +sudo chown -R $USER /opt && \ |
| 88 | + mkdir -p /opt/prrte && \ |
| 89 | + cd /opt/prrte && \ |
| 90 | + git clone https://github.com/openpmix/openpmix.git && \ |
| 91 | + git clone https://github.com/openpmix/prrte.git && \ |
| 92 | + cd openpmix && \ |
| 93 | + git checkout fefaed568f33bf86f28afb6e45237f1ec5e4de93 && \ |
| 94 | + ./autogen.pl && \ |
| 95 | + ./configure --prefix=/usr --disable-static && sudo make install && \ |
| 96 | + sudo ldconfig |
| 97 | + |
| 98 | + |
| 99 | +# prrte you are sure looking perrrty today |
| 100 | +cd /opt/prrte/prrte && \ |
| 101 | + git checkout 477894f4720d822b15cab56eee7665107832921c && \ |
| 102 | + ./autogen.pl && \ |
| 103 | + ./configure --prefix=/usr && sudo make -j install |
| 104 | + |
| 105 | +# flux security |
| 106 | +wget https://github.com/flux-framework/flux-security/releases/download/v0.11.0/flux-security-0.11.0.tar.gz && \ |
| 107 | + tar -xzvf flux-security-0.11.0.tar.gz && \ |
| 108 | + mv flux-security-0.11.0 /opt/flux-security && \ |
| 109 | + cd /opt/flux-security && \ |
| 110 | + ./configure --prefix=/usr --sysconfdir=/etc && \ |
| 111 | + make -j && sudo make install |
| 112 | + |
| 113 | +# The VMs will share the same munge key |
| 114 | +sudo mkdir -p /var/run/munge && \ |
| 115 | + dd if=/dev/urandom bs=1 count=1024 > munge.key && \ |
| 116 | + sudo mv munge.key /etc/munge/munge.key && \ |
| 117 | + sudo chown -R munge /etc/munge/munge.key /var/run/munge && \ |
| 118 | + sudo chmod 600 /etc/munge/munge.key |
| 119 | + |
| 120 | +# Make the flux run directory |
| 121 | +mkdir -p /home/ubuntu/run/flux |
| 122 | + |
| 123 | +# Flux core |
| 124 | +wget https://github.com/flux-framework/flux-core/releases/download/v0.66.0/flux-core-0.66.0.tar.gz && \ |
| 125 | + tar -xzvf flux-core-0.66.0.tar.gz && \ |
| 126 | + mv flux-core-0.66.0 /opt/flux-core && \ |
| 127 | + cd /opt/flux-core && \ |
| 128 | + ./configure --prefix=/usr --sysconfdir=/etc --runstatedir=/home/flux/run --with-flux-security && \ |
| 129 | + make clean && \ |
| 130 | + make -j && sudo make install |
| 131 | + |
| 132 | +# Flux pmix (must be installed after flux core) |
| 133 | +wget https://github.com/flux-framework/flux-pmix/releases/download/v0.5.0/flux-pmix-0.5.0.tar.gz && \ |
| 134 | + tar -xzvf flux-pmix-0.5.0.tar.gz && \ |
| 135 | + mv flux-pmix-0.5.0 /opt/flux-pmix && \ |
| 136 | + cd /opt/flux-pmix && \ |
| 137 | + ./configure --prefix=/usr && \ |
| 138 | + make -j && \ |
| 139 | + sudo make install |
| 140 | + |
| 141 | +# Flux sched |
| 142 | +wget https://github.com/flux-framework/flux-sched/releases/download/v0.37.0/flux-sched-0.37.0.tar.gz && \ |
| 143 | + tar -xzvf flux-sched-0.37.0.tar.gz && \ |
| 144 | + mv flux-sched-0.37.0 /opt/flux-sched && \ |
| 145 | + cd /opt/flux-sched && \ |
| 146 | + mkdir build && \ |
| 147 | + cd build && \ |
| 148 | + cmake ../ && make -j && sudo make install && sudo ldconfig && \ |
| 149 | + echo "DONE flux build" |
| 150 | + |
| 151 | +# Flux curve.cert |
| 152 | +# Ensure we have a shared curve certificate |
| 153 | +flux keygen /tmp/curve.cert && \ |
| 154 | + sudo mkdir -p /etc/flux/system && \ |
| 155 | + sudo cp /tmp/curve.cert /etc/flux/system/curve.cert && \ |
| 156 | + sudo chown ubuntu /etc/flux/system/curve.cert && \ |
| 157 | + sudo chmod o-r /etc/flux/system/curve.cert && \ |
| 158 | + sudo chmod g-r /etc/flux/system/curve.cert && \ |
| 159 | + # Permissions for imp |
| 160 | + sudo chmod u+s /usr/libexec/flux/flux-imp && \ |
| 161 | + sudo chmod 4755 /usr/libexec/flux/flux-imp && \ |
| 162 | + # /var/lib/flux needs to be owned by the instance owner |
| 163 | + sudo mkdir -p /var/lib/flux && \ |
| 164 | + sudo chown $USER -R /var/lib/flux && \ |
| 165 | + # clean up (and make space) |
| 166 | + cd /opt |
| 167 | + sudo rm -rf /opt/flux-core /opt/flux-sched /opt/prrte /opt/flux-security /opt/flux-pmix |
| 168 | + |
| 169 | +# Install oras and singularity |
| 170 | +export VERSION="1.1.0" && \ |
| 171 | +curl -LO "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_${ORAS_ARCH}.tar.gz" && \ |
| 172 | +mkdir -p oras-install/ && \ |
| 173 | +tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/ && \ |
| 174 | +sudo mv oras-install/oras /usr/local/bin/ && \ |
| 175 | +rm -rf oras_${VERSION}_*.tar.gz oras-install/ |
| 176 | + |
| 177 | +cd /opt |
| 178 | + |
| 179 | +# flux start mpirun -n 6 singularity exec singularity-mpi_mpich.sif /opt/mpitest |
| 180 | +sudo apt-get update && sudo apt-get install -y libseccomp-dev libglib2.0-dev cryptsetup \ |
| 181 | + libfuse-dev \ |
| 182 | + squashfs-tools \ |
| 183 | + squashfs-tools-ng \ |
| 184 | + uidmap \ |
| 185 | + zlib1g-dev \ |
| 186 | + iperf3 |
| 187 | + |
| 188 | +sudo apt-get install -y \ |
| 189 | + autoconf \ |
| 190 | + automake \ |
| 191 | + cryptsetup \ |
| 192 | + git \ |
| 193 | + libfuse-dev \ |
| 194 | + libglib2.0-dev \ |
| 195 | + libseccomp-dev \ |
| 196 | + libtool \ |
| 197 | + pkg-config \ |
| 198 | + runc \ |
| 199 | + squashfs-tools \ |
| 200 | + squashfs-tools-ng \ |
| 201 | + uidmap \ |
| 202 | + wget \ |
| 203 | + zlib1g-dev |
| 204 | + |
| 205 | +# install go |
| 206 | +wget https://go.dev/dl/go1.21.0.linux-${ORAS_ARCH}.tar.gz |
| 207 | +tar -xvf go1.21.0.linux-${ORAS_ARCH}.tar.gz |
| 208 | +sudo mv go /usr/local && rm go1.21.0.linux-${ORAS_ARCH}.tar.gz |
| 209 | +export PATH=/usr/local/go/bin:$PATH |
| 210 | + |
| 211 | +# Install singularity |
| 212 | +export VERSION=4.0.1 && \ |
| 213 | + wget https://github.com/sylabs/singularity/releases/download/v${VERSION}/singularity-ce-${VERSION}.tar.gz && \ |
| 214 | + tar -xzf singularity-ce-${VERSION}.tar.gz && \ |
| 215 | + cd singularity-ce-${VERSION} |
| 216 | + |
| 217 | +./mconfig && \ |
| 218 | + make -C builddir && \ |
| 219 | + sudo make -C builddir install |
| 220 | + |
| 221 | +# |
| 222 | +# At this point we have what we need! |
0 commit comments