github.com/pachyderm/pachyderm@v1.13.4/etc/deploy/gpu/install-nvidia-driver.sh (about)

     1  #!/bin/bash
     2  
     3  # Check if this script has already been run
     4  prefix="Pachyderm nvidia bootstrapper"
     5  command -v nvidia-smi
     6  if [[ $? -eq 0 ]]; then
     7      # If it has, do nothing
     8      echo "$prefix : Nvidia drivers already installed. Nothing to do"
     9      exit 0
    10  else
    11      apt-get install pciutils -y
    12      lspci -vnn | grep NVIDIA
    13      if [[ $? -ne 0 ]]; then
    14          # No NVIDIA card present, exit
    15          echo "$prefix: No NVIDIA GPU detected, exiting"
    16          exit 0
    17      fi
    18      set +euxo pipefail
    19      # If not ... install the drivers and restart
    20      NVIDIA_RUNNER=$1
    21      apt-get update
    22      apt-get install --yes gcc
    23      "./$NVIDIA_RUNNER" --ui=none --no-questions --accept-license
    24      # We want to overwrite, not append since the default
    25      # value of this file w our current AMI is just 'exit 0'
    26      echo "$prefix : Nvidia driver bootstrapper - updating rc.local"
    27      cp /etc/rc.local /etc/rc.local.bck
    28      cat >/etc/rc.local  <<EOL
    29  #!/bin/sh -e
    30  nvidia-smi -pm 1 || true
    31  nvidia-smi -acp 0 || true
    32  nvidia-smi --auto-boost-default=0 || true
    33  nvidia-smi --auto-boost-permission=0 || true
    34  nvidia-modprobe -u -c=0 -m || true
    35  EOL
    36      echo "$prefix : Updated /etc/rc.local:"
    37      cat /etc/rc.local
    38      /sbin/shutdown -r   
    39  fi