diff --git a/spark-rapids/README.md b/spark-rapids/README.md index 92f55fea3..c55dc59ed 100644 --- a/spark-rapids/README.md +++ b/spark-rapids/README.md @@ -106,6 +106,10 @@ profile id or the name (ie 3g.20gb) can be specified. For example: --metadata=^:^MIG_CGI='3g.20gb,9' ``` Create cluster with MIG enabled: + + The MIG startup script runs only on worker nodes. It skips the master node + so that the required MIG reboot does not interrupt Dataproc master service + initialization. ```bash REGION= diff --git a/spark-rapids/mig.sh b/spark-rapids/mig.sh index 6d0874ff3..8d9ec4ca9 100644 --- a/spark-rapids/mig.sh +++ b/spark-rapids/mig.sh @@ -26,6 +26,8 @@ set -euxo pipefail +readonly ROLE="$(/usr/share/google/get_metadata_value attributes/dataproc-role)" + function os_id() { grep '^ID=' /etc/os-release | cut -d= -f2 | xargs } @@ -50,6 +52,10 @@ function is_debian12() { is_debian && [[ "$(os_version)" == '12'* ]] } +function is_debian13() { + is_debian && [[ "$(os_version)" == '13'* ]] +} + function is_ubuntu() { [[ "$(os_id)" == 'ubuntu' ]] } @@ -66,6 +72,10 @@ function is_ubuntu22() { is_ubuntu && [[ "$(os_version)" == '22.04'* ]] } +function is_ubuntu24() { + is_ubuntu && [[ "$(os_version)" == '24.04'* ]] +} + function is_rocky() { [[ "$(os_id)" == 'rocky' ]] } @@ -94,6 +104,26 @@ function get_metadata_attribute() { /usr/share/google/get_metadata_value "attributes/${attribute_name}" || echo -n "${default_value}" } +REBOOT_FOR_CGROUP_V1=0 + +function configure_cgroup_v1_for_yarn_gpu_isolation() { + if ! is_debian13 || [[ ! -f /sys/fs/cgroup/cgroup.controllers ]]; then + return + fi + + # YARN's GPU isolation requires the cgroup v1 devices controller. Debian 13 + # defaults to cgroup v2, and systemd 257 requires both kernel parameters to + # temporarily enable its legacy hierarchy. + local -r cgroup_v1_params="systemd.unified_cgroup_hierarchy=0 SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1" + if ! grep -q 'SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1' /etc/default/grub; then + sed -i \ + "s|^GRUB_CMDLINE_LINUX_DEFAULT=\"\\(.*\\)\"|GRUB_CMDLINE_LINUX_DEFAULT=\"\\1 ${cgroup_v1_params}\"|" \ + /etc/default/grub + update-grub + fi + REBOOT_FOR_CGROUP_V1=1 +} + CA_TMPDIR="$(mktemp -u -d -p /run/tmp -t ca_dir-XXXX)" PSN="$(get_metadata_attribute private_secret_name)" readonly PSN @@ -172,11 +202,11 @@ function configure_dkms_certs() { function clear_dkms_key { if [[ -z "${PSN}" ]]; then - echo "No signing secret provided. skipping" >2 + echo "No signing secret provided. skipping" >&2 return 0 fi - echo "WARN -- PURGING SIGNING MATERIAL -- WARN" >2 - echo "future dkms runs will not use correct signing key" >2 + echo "WARN -- PURGING SIGNING MATERIAL -- WARN" >&2 + echo "future dkms runs will not use correct signing key" >&2 rm -rf "${CA_TMPDIR}" /var/lib/dkms/mok.key /var/lib/shim-signed/mok/MOK.priv } @@ -184,7 +214,7 @@ function add_contrib_components() { if ! is_debian ; then return fi - if is_debian12 ; then + if is_debian12 || is_debian13 ; then # Include in sources file components on which nvidia-open-kernel-dkms depends local -r debian_sources="/etc/apt/sources.list.d/debian.sources" local components="main contrib" @@ -217,12 +247,38 @@ NVIDIA_DRIVER_VERSION=$(get_metadata_attribute 'driver-version' '550.54.15') #53 CUDA_VERSION_MAJOR="${CUDA_VERSION%.*}" #12.2 # EXCEPTIONS -# Change CUDA version for Ubuntu 18 (Cuda 12.1.1 - Driver v530.30.02 is the latest version supported by Ubuntu 18) +# Debian 12 security kernels use the four-argument pci_resize_resource API, +# which is incompatible with NVIDIA 550 open modules. +if is_debian12 ; then + NVIDIA_DRIVER_VERSION=$(get_metadata_attribute 'driver-version' '580.95.05') + if [[ "${NVIDIA_DRIVER_VERSION%%.*}" == "550" ]]; then + echo "WARNING: Driver version 550 is incompatible with Debian 12 kernel. Overriding to 580.95.05" >&2 + NVIDIA_DRIVER_VERSION='580.95.05' + fi + USE_REPO_INSTALL="true" +elif is_debian13 ; then + # The Debian 13 repository starts at driver 590 and CUDA 13. + CUDA_VERSION=$(get_metadata_attribute 'cuda-version' '13.0') + NVIDIA_DRIVER_VERSION=$(get_metadata_attribute 'driver-version' '590') + CUDA_VERSION_MAJOR="${CUDA_VERSION%.*}" + if [[ "${NVIDIA_DRIVER_VERSION%%.*}" -lt 590 ]]; then + echo "WARNING: Driver version ${NVIDIA_DRIVER_VERSION} is unavailable for Debian 13. Overriding to 590" >&2 + NVIDIA_DRIVER_VERSION='590' + fi + USE_REPO_INSTALL="true" +fi + +# Change CUDA and driver versions for Ubuntu-specific repository availability. if [[ "${OS_NAME}" == "ubuntu" ]]; then if is_ubuntu18 ; then CUDA_VERSION=$(get_metadata_attribute 'cuda-version' '12.1.1') #12.1.1 NVIDIA_DRIVER_VERSION=$(get_metadata_attribute 'driver-version' '530.30.02') #530.30.02 CUDA_VERSION_MAJOR="${CUDA_VERSION%.*}" #12.1 + elif is_ubuntu24 ; then + CUDA_VERSION=$(get_metadata_attribute 'cuda-version' '12.6.0') + NVIDIA_DRIVER_VERSION=$(get_metadata_attribute 'driver-version' '580.95.05') + CUDA_VERSION_MAJOR="${CUDA_VERSION%.*}" + USE_REPO_INSTALL="true" fi fi @@ -296,30 +352,51 @@ function install_nvidia_gpu_driver() { execute_with_retries "apt-get install -y -q 'linux-headers-$(uname -r)'" - curl -fsSL --retry-connrefused --retry 3 --retry-max-time 5 \ - "${LOCAL_DEB_URL}" -o /tmp/local-installer.deb + if [[ "${USE_REPO_INSTALL:-false}" == "true" ]]; then + execute_with_retries \ + "curl -fsSL --retry-connrefused --retry 3 --retry-max-time 5 https://developer.download.nvidia.com/compute/cuda/repos/${shortname}/x86_64/cuda-keyring_1.1-1_all.deb -o /tmp/cuda-keyring_1.1-1_all.deb" + execute_with_retries "dpkg -i /tmp/cuda-keyring_1.1-1_all.deb" + rm -f /tmp/cuda-keyring_1.1-1_all.deb + add_contrib_components + execute_with_retries "apt-get update" - dpkg -i /tmp/local-installer.deb - rm /tmp/local-installer.deb - cp ${DIST_KEYRING_DIR}/cuda-*-keyring.gpg /usr/share/keyrings/ + execute_with_retries "apt-get install -y -q --no-install-recommends dkms" + execute_with_retries \ + "apt-get install -y -q --no-install-recommends nvidia-driver-pinning-${NVIDIA_DRIVER_VERSION_PREFIX}" - add_contrib_components + configure_dkms_certs + execute_with_retries \ + "apt-get install -y -q --no-install-recommends nvidia-kernel-open-dkms nvidia-driver-cuda" + clear_dkms_key - execute_with_retries "apt-get update" + execute_with_retries \ + "apt-get install -y -q --no-install-recommends cuda-toolkit-${CUDA_VERSION_MAJOR//./-}" + else + curl -fsSL --retry-connrefused --retry 3 --retry-max-time 5 \ + "${LOCAL_DEB_URL}" -o /tmp/local-installer.deb - ## EXCEPTION - if is_debian10 ; then - apt-get remove -y libglvnd0 - apt-get install -y ca-certificates-java - fi + dpkg -i /tmp/local-installer.deb + rm /tmp/local-installer.deb + cp ${DIST_KEYRING_DIR}/cuda-*-keyring.gpg /usr/share/keyrings/ - configure_dkms_certs - execute_with_retries "apt-get install -y -q nvidia-kernel-open-dkms" - clear_dkms_key - execute_with_retries \ - "apt-get install -y -q --no-install-recommends cuda-drivers-${NVIDIA_DRIVER_VERSION_PREFIX}" - execute_with_retries \ - "apt-get install -y -q --no-install-recommends cuda-toolkit-${CUDA_VERSION_MAJOR//./-}" + add_contrib_components + + execute_with_retries "apt-get update" + + ## EXCEPTION + if is_debian10 ; then + apt-get remove -y libglvnd0 + apt-get install -y ca-certificates-java + fi + + configure_dkms_certs + execute_with_retries "apt-get install -y -q nvidia-kernel-open-dkms" + clear_dkms_key + execute_with_retries \ + "apt-get install -y -q --no-install-recommends cuda-drivers-${NVIDIA_DRIVER_VERSION_PREFIX}" + execute_with_retries \ + "apt-get install -y -q --no-install-recommends cuda-toolkit-${CUDA_VERSION_MAJOR//./-}" + fi modprobe nvidia @@ -381,6 +458,20 @@ function install_nvidia_gpu_driver() { -o cuda.run bash cuda.run --silent --toolkit --no-opengl-libs rm cuda.run + elif [[ "${USE_REPO_INSTALL:-false}" == "true" ]]; then + execute_with_retries \ + "curl -fsSL --retry-connrefused --retry 3 --retry-max-time 5 https://developer.download.nvidia.com/compute/cuda/repos/${shortname}/x86_64/cuda-keyring_1.1-1_all.deb -o /tmp/cuda-keyring_1.1-1_all.deb" + execute_with_retries "dpkg -i /tmp/cuda-keyring_1.1-1_all.deb" + rm -f /tmp/cuda-keyring_1.1-1_all.deb + execute_with_retries "apt-get update" + + execute_with_retries "apt-get install -y -q --no-install-recommends dkms" + configure_dkms_certs + for pkg in "nvidia-driver-${NVIDIA_DRIVER_VERSION_PREFIX}-open" \ + "cuda-toolkit-${CUDA_VERSION_MAJOR//./-}" ; do + execute_with_retries "apt-get install -y -q --no-install-recommends ${pkg}" + done + clear_dkms_key else # Install from repo provided by NV readonly UBUNTU_REPO_CUDA_PIN="${NVIDIA_REPO_URL}/cuda-${shortname}.pin" @@ -454,12 +545,12 @@ function configure_mig_cgi() { # Verify if compatible linux distros and secure boot options are used function check_os_and_secure_boot() { if is_debian ; then - if ! is_debian10 && ! is_debian11 && ! is_debian12 ; then + if ! is_debian10 && ! is_debian11 && ! is_debian12 && ! is_debian13 ; then echo "Error: The Debian version ($(os_version)) is not supported. Please use a compatible Debian version." exit 1 fi elif is_ubuntu ; then - if ! is_ubuntu18 && ! is_ubuntu20 && ! is_ubuntu22 ; then + if ! is_ubuntu18 && ! is_ubuntu20 && ! is_ubuntu22 && ! is_ubuntu24 ; then echo "Error: The Ubuntu version ($(os_version)) is not supported. Please use a compatible Ubuntu version." exit 1 fi @@ -503,6 +594,15 @@ function remove_old_backports { } function main() { + # Rebooting a master before Dataproc initialization completes causes its + # master-only services to be initialized twice. MIG is only needed on workers. + # Note: Single-node clusters (where ROLE=Master and primary workers=0) will + # skip MIG configuration by design. + if [[ "${ROLE}" == "Master" ]]; then + echo "Skipping MIG setup and reboot on Dataproc master" + return + fi + if [[ ${OS_NAME} == debian ]] && [[ $(echo "${DATAPROC_IMAGE_VERSION} <= 2.1" | bc -l) == 1 ]]; then remove_old_backports fi @@ -527,6 +627,7 @@ function main() { fi if (lspci | grep -q NVIDIA); then + configure_cgroup_v1_for_yarn_gpu_isolation if [[ $META_MIG_VALUE -ne 0 ]]; then # if the first invocation, the NVIDIA drivers and tools are not installed if [[ -f "/usr/bin/nvidia-smi" ]]; then @@ -535,6 +636,11 @@ function main() { NUM_GPUS_WITH_DIFF_MIG_MODES=`/usr/bin/nvidia-smi --query-gpu=mig.mode.current --format=csv,noheader | uniq | wc -l` if [[ $NUM_GPUS_WITH_DIFF_MIG_MODES -eq 1 ]]; then if (/usr/bin/nvidia-smi --query-gpu=mig.mode.current --format=csv,noheader | grep Enabled); then + if [[ $REBOOT_FOR_CGROUP_V1 -ne 0 ]]; then + echo "Rebooting to enable the cgroup v1 devices controller" + reboot + exit 0 + fi echo "MIG is enabled on all GPUs, configuring instances" configure_mig_cgi exit 0 @@ -560,6 +666,11 @@ function main() { if [[ ${META_MIG_VALUE} -ne 0 ]]; then enable_mig + if [[ $REBOOT_FOR_CGROUP_V1 -ne 0 ]]; then + echo "Rebooting to enable MIG and the cgroup v1 devices controller" + reboot + exit 0 + fi NUM_GPUS_WITH_DIFF_MIG_MODES=`/usr/bin/nvidia-smi --query-gpu=mig.mode.current --format=csv,noheader | uniq | wc -l` if [[ NUM_GPUS_WITH_DIFF_MIG_MODES -eq 1 ]]; then if (/usr/bin/nvidia-smi --query-gpu=mig.mode.current --format=csv,noheader | grep Enabled); then @@ -575,6 +686,10 @@ function main() { fi else echo "Not enabling MIG" + if [[ $REBOOT_FOR_CGROUP_V1 -ne 0 ]]; then + echo "Rebooting to enable the cgroup v1 devices controller" + reboot + fi fi fi } diff --git a/spark-rapids/spark-rapids.sh b/spark-rapids/spark-rapids.sh index 760f8259e..310f792d1 100644 --- a/spark-rapids/spark-rapids.sh +++ b/spark-rapids/spark-rapids.sh @@ -45,6 +45,14 @@ function is_debian12() { is_debian && [[ "$(os_version)" == '12'* ]] } +function is_debian13() { + is_debian && [[ "$(os_version)" == '13'* ]] +} + +function is_cgroup_v2() { + [[ -f /sys/fs/cgroup/cgroup.controllers ]] +} + function is_ubuntu() { [[ "$(os_id)" == 'ubuntu' ]] } @@ -312,11 +320,11 @@ function configure_dkms_certs() { function clear_dkms_key { if [[ -z "${PSN}" ]]; then - echo "No signing secret provided. skipping" >2 + echo "No signing secret provided. skipping" >&2 return 0 fi - echo "WARN -- PURGING SIGNING MATERIAL -- WARN" >2 - echo "future dkms runs will not use correct signing key" >2 + echo "WARN -- PURGING SIGNING MATERIAL -- WARN" >&2 + echo "future dkms runs will not use correct signing key" >&2 rm -rf "${CA_TMPDIR}" /var/lib/dkms/mok.key /var/lib/shim-signed/mok/MOK.priv } @@ -324,7 +332,7 @@ function add_contrib_components() { if ! is_debian ; then return fi - if is_debian12 ; then + if is_debian12 || is_debian13 ; then # Include in sources file components on which nvidia-open-kernel-dkms depends local -r debian_sources="/etc/apt/sources.list.d/debian.sources" local components="main contrib" @@ -367,7 +375,7 @@ else fi # Update SPARK RAPIDS config -readonly HARDCODED_RAPIDS_VERSION="26.08.1" +readonly HARDCODED_RAPIDS_VERSION="26.10.0" # 1. Try to get explicit version from GCE Metadata SPARK_RAPIDS_VERSION=$(get_metadata_attribute 'spark-rapids-version' '') @@ -426,6 +434,16 @@ if is_debian12 ; then NVIDIA_DRIVER_VERSION='580.95.05' fi USE_REPO_INSTALL="true" +elif is_debian13 ; then + # The Debian 13 repository starts at driver 590 and CUDA 13. + CUDA_VERSION=$(get_metadata_attribute 'cuda-version' '13.0') + NVIDIA_DRIVER_VERSION=$(get_metadata_attribute 'driver-version' '590') + CUDA_VERSION_MAJOR="${CUDA_VERSION%.*}" + if [[ "${NVIDIA_DRIVER_VERSION%%.*}" -lt 590 ]]; then + echo "WARNING: Driver version ${NVIDIA_DRIVER_VERSION} is unavailable for Debian 13. Overriding to 590" >&2 + NVIDIA_DRIVER_VERSION='590' + fi + USE_REPO_INSTALL="true" fi # Change CUDA version for Ubuntu 18 (Cuda 12.1.1 - Driver v530.30.02 is the latest version supported by Ubuntu 18) @@ -663,6 +681,7 @@ function install_nvidia_gpu_driver() { "curl -fsSL --retry-connrefused --retry 3 --retry-max-time 5 https://developer.download.nvidia.com/compute/cuda/repos/${shortname}/x86_64/cuda-keyring_1.1-1_all.deb -o /tmp/cuda-keyring_1.1-1_all.deb" execute_with_retries "dpkg -i /tmp/cuda-keyring_1.1-1_all.deb" rm -f /tmp/cuda-keyring_1.1-1_all.deb + add_contrib_components execute_with_retries "apt-get update" execute_with_retries "apt-get install -y -q --no-install-recommends dkms" @@ -978,6 +997,14 @@ function configure_yarn_nodemanager() { 'yarn.nodemanager.resource-plugins.gpu.allowed-gpu-devices' 'auto' set_hadoop_property 'yarn-site.xml' \ 'yarn.nodemanager.resource-plugins.gpu.path-to-discovery-executables' $NVIDIA_SMI_PATH + + # YARN's GPU isolation requires the cgroup v1 devices controller, which is + # not available with the unified cgroup v2 hierarchy. + if is_cgroup_v2; then + echo "WARNING: cgroup v2 detected; configuring GPU scheduling without cgroup device isolation." >&2 + return + fi + set_hadoop_property 'yarn-site.xml' \ 'yarn.nodemanager.linux-container-executor.cgroups.mount' 'true' set_hadoop_property 'yarn-site.xml' \ @@ -1048,6 +1075,10 @@ echo {\"name\": \"gpu\", \"addresses\":[\"$ADDRS\"]} } function configure_gpu_isolation() { + if is_cgroup_v2; then + return + fi + # enable GPU isolation sed -i "s/yarn\.nodemanager\.linux\-container\-executor\.group\=.*$/yarn\.nodemanager\.linux\-container\-executor\.group\=yarn/g" "${HADOOP_CONF_DIR}/container-executor.cfg" if [[ $IS_MIG_ENABLED -ne 0 ]]; then @@ -1065,7 +1096,7 @@ function configure_gpu_isolation() { Description=Set permissions to allow YARN to access device directories [Service] -ExecStart=/bin/bash -c "chmod a+rwx -R /sys/fs/cgroup/cpu,cpuacct; chmod a+rwx -R /sys/fs/cgroup/devices" +ExecStart=/bin/bash -c "if [[ -d /sys/fs/cgroup/cpu,cpuacct ]]; then chmod a+rwx -R /sys/fs/cgroup/cpu,cpuacct; fi; if [[ -d /sys/fs/cgroup/devices ]]; then chmod a+rwx -R /sys/fs/cgroup/devices; fi" [Install] WantedBy=multi-user.target @@ -1147,7 +1178,7 @@ function setup_gpu_yarn() { # Verify if compatible linux distros and secure boot options are used function check_os_and_secure_boot() { if is_debian ; then - if ! is_debian10 && ! is_debian11 && ! is_debian12 ; then + if ! is_debian10 && ! is_debian11 && ! is_debian12 && ! is_debian13 ; then echo "Error: The Debian version ($(os_version)) is not supported. Please use a compatible Debian version." exit 1 fi