1# Copyright 2022 Google Inc. All rights reserved. 2 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6 7# http://www.apache.org/licenses/LICENSE-2.0 8 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set -x 16set -o errexit 17 18arch=$(uname -m) 19nvidia_arch=${arch} 20[ "${arch}" = "x86_64" ] && arch=amd64 21[ "${arch}" = "aarch64" ] && arch=arm64 22 23# NVIDIA driver needs dkms which requires /dev/fd 24if [ ! -d /dev/fd ]; then 25 ln -s /proc/self/fd /dev/fd 26fi 27 28# Using "Depends:" is more reliable than "Version:", because it works for 29# backported ("bpo") kernels as well. NOTE: "Package" can be used instead 30# if we don't install the metapackage ("linux-image-cloud-${arch}") but a 31# specific version in the future 32kmodver=$(dpkg -s linux-image-cloud-${arch} | grep ^Depends: | \ 33 cut -d: -f2 | cut -d" " -f2 | sed 's/linux-image-//') 34 35apt-get install -y wget 36# Install headers from backports, to match the linux-image 37apt-get install -y -t bullseye-backports $(echo linux-headers-${kmodver}) 38# Dependencies for nvidia-installer 39apt-get install -y dkms libglvnd-dev libc6-dev pkg-config 40 41nvidia_version=525.85.12 42 43wget -q https://us.download.nvidia.com/tesla/${nvidia_version}/NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run 44chmod a+x NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run 45./NVIDIA-Linux-${nvidia_arch}-${nvidia_version}.run -x 46NVIDIA-Linux-${nvidia_arch}-${nvidia_version}/nvidia-installer --silent --no-install-compat32-libs --no-backup --no-wine-files --install-libglvnd --dkms -k "${kmodver}" 47 48