From 728ca2d18469678e22070cc37764b7f1d91cdf3c Mon Sep 17 00:00:00 2001 From: KeithMnemonic Date: Fri, 2 Aug 2024 11:56:00 -0400 Subject: [PATCH] Add a new nvidia-gpu-services.target to ensure proper startup order --- deployments/systemd/install.sh | 5 +++++ deployments/systemd/nvidia-gpu-services.target | 16 ++++++++++++++++ deployments/systemd/nvidia-mig-manager.service | 7 ++++--- deployments/systemd/uninstall.sh | 4 ++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 deployments/systemd/nvidia-gpu-services.target diff --git a/deployments/systemd/install.sh b/deployments/systemd/install.sh index c24d736f..7318aba6 100755 --- a/deployments/systemd/install.sh +++ b/deployments/systemd/install.sh @@ -19,6 +19,9 @@ SERVICE_ROOT="nvidia-mig-manager" SERVICE_NAME="${SERVICE_ROOT}.service" +GPU_TARGET_ROOT="nvidia-gpu-services" +GPU_TARGET_NAME="${GPU_TARGET_ROOT}.target" + MIG_PARTED_NAME="nvidia-mig-parted" MIG_PARTED_GO_GET_PATH="github.com/NVIDIA/mig-parted/cmd/${MIG_PARTED_NAME}" @@ -52,6 +55,7 @@ ${DOCKER} run --rm \ " cp ${SERVICE_NAME} ${SYSTEMD_DIR} +cp ${GPU_TARGET_NAME} ${SYSTEMD_DIR} cp ${MIG_PARTED_NAME}.sh ${PROFILED_DIR} cp override.conf ${OVERRIDE_DIR} cp service.sh ${CONFIG_DIR} @@ -62,6 +66,7 @@ cp hooks-minimal.yaml ${CONFIG_DIR} cp config-default.yaml ${CONFIG_DIR} chmod a+r ${SYSTEMD_DIR}/${SERVICE_NAME} +chmod a+r ${SYSTEMD_DIR}/${GPU_TARGET_NAME} chmod a+r ${PROFILED_DIR}/${MIG_PARTED_NAME}.sh chmod a+r ${OVERRIDE_DIR}/override.conf chmod a+r ${CONFIG_DIR}/service.sh diff --git a/deployments/systemd/nvidia-gpu-services.target b/deployments/systemd/nvidia-gpu-services.target new file mode 100644 index 00000000..b9265d74 --- /dev/null +++ b/deployments/systemd/nvidia-gpu-services.target @@ -0,0 +1,16 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[Unit] +Description=Nvidia GPU System Target diff --git a/deployments/systemd/nvidia-mig-manager.service b/deployments/systemd/nvidia-mig-manager.service index 26d6318c..f3e613c0 100644 --- a/deployments/systemd/nvidia-mig-manager.service +++ b/deployments/systemd/nvidia-mig-manager.service @@ -15,12 +15,13 @@ [Unit] Description=Configure MIG on NVIDIA GPUs DefaultDependencies=no -After=sysinit.target local-fs.target -Before=basic.target nvidia-persistenced.service systemd-resolved.service +Wants=nvidia-persistenced.service nvidia-fabricmanager.service +After=nvidia-persistenced.service nvidia-fabricmanager.service +Before=nvidia-gpu-services.target [Service] Type=oneshot ExecStart=-/bin/bash /etc/nvidia-mig-manager/service.sh [Install] -WantedBy=multi-user.target +WantedBy=nvidia-gpu-services.target diff --git a/deployments/systemd/uninstall.sh b/deployments/systemd/uninstall.sh index 0ace1866..5e771821 100755 --- a/deployments/systemd/uninstall.sh +++ b/deployments/systemd/uninstall.sh @@ -17,6 +17,9 @@ SERVICE_ROOT="nvidia-mig-manager" SERVICE_NAME="${SERVICE_ROOT}.service" +GPU_TARGET_ROOT="nvidia-gpu-services" +GPU_TARGET_NAME="${GPU_TARGET_ROOT}.target" + MIG_PARTED_NAME="nvidia-mig-parted" MIG_PARTED_GO_GET_PATH="github.com/NVIDIA/mig-parted/cmd/${MIG_PARTED_NAME}" @@ -36,4 +39,5 @@ rm -rf ${OVERRIDE_DIR} rm ${BINARY_DIR}/${MIG_PARTED_NAME} rm ${SYSTEMD_DIR}/${SERVICE_NAME} +rm ${SYSTEMD_DIR}/${GPU_TARGET_NAME} rm ${PROFILED_DIR}/${MIG_PARTED_NAME}.sh