Skip to content

playbooks: run nvidia-smi tasks outside the ssh cgroup so they survive the login GPU guard - #1397

Open
100-JM wants to merge 2 commits into
NVIDIA:masterfrom
100-JM:fix/gpu-tasks-escape-ssh-device-guard
Open

playbooks: run nvidia-smi tasks outside the ssh cgroup so they survive the login GPU guard#1397
100-JM wants to merge 2 commits into
NVIDIA:masterfrom
100-JM:fix/gpu-tasks-escape-ssh-device-guard

Conversation

@100-JM

@100-JM 100-JM commented Sep 6, 2026

Copy link
Copy Markdown

Problem

With slurm_login_on_compute: true, roles/slurm/tasks/login-compute-setup.yml sets DeviceAllow=/dev/nvidiactl on the ssh service so users cannot touch GPUs outside a Slurm job. Ansible connects through that same ssh service, so its own processes land in the restricted cgroup (/system.slice/ssh.service) and become does not change that — the device filter is per cgroup, not per user. Every task that runs nvidia-smi after the guard is applied therefore sees no GPUs:

$ nvidia-smi; echo rc=$?                      # in an ssh session on the node
No devices were found
rc=6

This breaks the second Ansible run that docs/slurm-cluster/slurm-single-node.md asks for ("reboot manually when prompted and then run Ansible again"):

task effect once the guard is active
playbooks/utilities/gpu-clocks.ymlnvidia-smi -acp UNRESTRICTED rc=6 → play fails (when allow_user_set_gpu_clocks: yes)
playbooks/nvidia-software/nvidia-cuda.ymltest nvidia-smi rc=6 → play fails (default slurm_cluster_install_cuda: yes)
playbooks/nvidia-software/nvidia-mig.yml… | grep -v 'N/A' rc=0 with No devices were found → treated as a MIG-capable node
roles/nvidia-mig-manager/tasks/main.yml — same probe, same filter same misdetection inside the role
playbooks/utilities/nvidia-set-gpu-clocks.ymlnvidia-smi -lgc/-rgc rc=6 → play fails

scripts/validation/validate_slurm.py already documents the phenomenon for the validator and uses srun as the authoritative test; the playbook tasks above were still running plainly over ssh.

Observed on a DGX B300, DGX OS 7.5.0, driver 580.126.20, DeepOps master.

Fix

Run every one of those nvidia-smi invocations through systemd-run --wait --pipe --collect --quiet. The command executes in a transient unit under system.slice, outside the ssh cgroup, so the check still runs for real instead of being skipped. Both MIG probes (playbook and role) now accept only Enabled/Disabled and get an explicit become: true (the rest of that play/role already requires root). Behaviour on nodes without the guard is unchanged.

nvidia-driver.yml carries the same test nvidia-smi; it is deliberately not touched here to avoid conflicting with #1396, and can take the same wrapper once that lands.

Side note: nvidia-smi -acp is deprecated in current drivers ("This option is deprecated … Treating as warning and moving on") and has no effect on Blackwell; a comment records that, the task is kept as-is otherwise.

Verification

On the affected node with the guard active, same ssh session:

$ nvidia-smi -L; echo rc=$?
No devices were found
rc=6
$ sudo systemd-run --wait --pipe --collect --quiet nvidia-smi -L; echo rc=$?
GPU 0: NVIDIA B300 SXM6 AC (UUID: GPU-364baba8-…)
…
GPU 7: NVIDIA B300 SXM6 AC (UUID: GPU-95bf3df7-…)
rc=0

ansible-playbook --syntax-check passes for the four playbooks; ansible-lint 26.1.1 with the project config reports 0 failures. systemd-run --wait/--pipe/--collect need systemd ≥ 236, which every supported Ubuntu/RHEL release ships.

…e the login GPU guard

With slurm_login_on_compute enabled, login-compute-setup restricts the ssh
service's cgroup to /dev/nvidiactl so interactive users cannot reach GPUs
outside a Slurm job. Ansible arrives over the same ssh service, so every
task that runs nvidia-smi afterwards is restricted too (the filter is
per-cgroup, become does not help):

  nvidia-smi                      -> rc=6, "No devices were found"
  nvidia-smi -acp UNRESTRICTED    -> rc=6
  nvidia-smi --query-gpu=mig.mode -> rc=0 with "No devices were found"

That breaks the second run slurm-single-node.md asks for ("reboot manually
when prompted and then run Ansible again"): gpu-clocks.yml and the
nvidia-cuda.yml driver test fail, and nvidia-mig.yml treats the
"No devices" text as a MIG-capable GPU because it only filtered 'N/A'.

Run those nvidia-smi invocations through
`systemd-run --wait --pipe --collect --quiet`. The command executes in a
transient unit under system.slice, outside the ssh cgroup, so the check
is still real instead of being skipped. Make the MIG probe accept only
Enabled/Disabled. nvidia-driver.yml has the same test; it is left alone
here to avoid conflicting with NVIDIA#1396 and can take the same wrapper after
that lands.

Verified on a DGX B300 (DGX OS 7.5.0, driver 580.126.20) with the guard
active: plain nvidia-smi in the ssh session returns rc=6, while
`sudo systemd-run --wait --pipe --collect --quiet nvidia-smi -L` lists all
eight GPUs with rc=0.

Signed-off-by: 백지명 <wlaud9805@gmail.com>
…-smi call sites

The nvidia-mig-manager role repeats the MIG probe that nvidia-mig.yml
runs, with the same 'grep -v N/A' filter, and
utilities/nvidia-set-gpu-clocks.yml locks/resets clocks with plain
nvidia-smi. Both run over the Ansible connection and hit the same
ssh-cgroup device guard on slurm_login_on_compute nodes.

Apply the same systemd-run wrapper, accept only Enabled/Disabled from
the MIG probe, and make that probe become root explicitly since the
rest of the role already requires it.

Signed-off-by: 백지명 <wlaud9805@gmail.com>
@100-JM
100-JM marked this pull request as ready for review September 6, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant