18713: disable the nvidia-persistenced service in the compute image.
[arvados.git] / tools / compute-images / scripts / base.sh
index e70eccd0c228e5351123a82e050f4ab7261dcd90..b30ad38d16693654bae65ea167f75255c36c2ff4 100644 (file)
@@ -64,7 +64,6 @@ wait_for_apt_locks && $SUDO DEBIAN_FRONTEND=noninteractive apt-get -qq --yes ins
 # Install the Arvados packages we need
 wait_for_apt_locks && $SUDO DEBIAN_FRONTEND=noninteractive apt-get -qq --yes install \
   python3-arvados-fuse \
-  crunch-run \
   arvados-docker-cleaner \
   docker.io
 
@@ -151,9 +150,16 @@ $SUDO mv /tmp/etc-cloud-cloud.cfg.d-07_compute_arvados_dispatch_cloud.cfg /etc/c
 $SUDO chown root:root /etc/cloud/cloud.cfg.d/07_compute_arvados_dispatch_cloud.cfg
 
 if [ "$NVIDIA_GPU_SUPPORT" == "1" ]; then
-  DIST=$(. /etc/os-release; echo $ID$VERSION_ID)
+  # $DIST should not have a dot if there is one in /etc/os-release (e.g. 18.04)
+  DIST=$(. /etc/os-release; echo $ID$VERSION_ID | tr -d '.')
   # We need a kernel and matching headers
-  $SUDO apt-get -y install linux-image-cloud-amd64 linux-headers-cloud-amd64
+  if [[ "$DIST" =~ ^debian ]]; then
+    $SUDO apt-get -y install linux-image-cloud-amd64 linux-headers-cloud-amd64
+  elif [ "$CLOUD" == "azure" ]; then
+    $SUDO apt-get -y install linux-image-azure linux-headers-azure
+  elif [ "$CLOUD" == "aws" ]; then
+    $SUDO apt-get -y install linux-image-aws linux-headers-aws
+  fi
 
   # Install CUDA
   $SUDO apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$DIST/x86_64/7fa2af80.pub
@@ -175,6 +181,8 @@ if [ "$NVIDIA_GPU_SUPPORT" == "1" ]; then
       $SUDO tee /etc/apt/sources.list.d/libnvidia-container.list
     $SUDO sed -i -e '/experimental/ s/^#//g' /etc/apt/sources.list.d/libnvidia-container.list
   else
+    # here, $DIST should have a dot if there is one in /etc/os-release (e.g. 18.04)...
+    DIST=$(. /etc/os-release; echo $ID$VERSION_ID)
     curl -s -L https://nvidia.github.io/libnvidia-container/$DIST/libnvidia-container.list | \
       $SUDO tee /etc/apt/sources.list.d/libnvidia-container.list
   fi
@@ -199,6 +207,11 @@ if [ "$NVIDIA_GPU_SUPPORT" == "1" ]; then
   fi
   $SUDO apt-get update
   $SUDO apt-get -y install libnvidia-container1 libnvidia-container-tools nvidia-container-toolkit
+  # This service fails to start when the image is booted without Nvidia GPUs present, which makes
+  # `systemctl is-system-running` respond with "degraded" and since that command is our default
+  # BootProbeCommand, compute nodes never finish booting from Arvados' perspective.
+  # Disable the service to avoid this.
+  $SUDO systemctl disable nvidia-persistenced.service
 fi
 
 $SUDO apt-get clean