playbooks: run nvidia-smi tasks outside the ssh cgroup so they survive the login GPU guard - #1397
Conversation
…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>
Adapt the second-convergence diagnosis and approach proposed in #1397. Co-authored-by: 백지명 <wlaud9805@gmail.com>
dholt
left a comment
There was a problem hiding this comment.
The transient-service approach addresses the SSH device restriction, but the complete MIG path still needs attention:
nvidia-mig-parted applyandassertstill run directly in the restricted SSH context. Once the repaired probe succeeds, those GPU operations can still fail. Apply the same privileged isolation to them.- Both probes suppress command failure and use it to skip configuration. Distinguish a successful unsupported-device result from a failed GPU query or transient service; an operational failure must not look like successful configuration.
- #1396 is now closed without merging, so its driver-check correction will not land there. Please include the remaining driver-check dependency here.
Please cover failed queries, unsupported devices, apply/assert failures and a repeated run with the SSH restriction already active. Keep the ordinary login restriction intact.
Address the review on running GPU tasks outside the login device guard. The MIG probe was the only part of the MIG path that escaped the cgroup. `nvidia-mig-parted apply` and `assert` drive the very same GPUs, so once the repaired probe succeeds they still ran in the restricted ssh context and failed there. They now run in a transient unit as well, and the play runs privileged, which the standalone `nvidia-mig-parted` invocations needed anyway. `nvidia-driver.yml`'s `test nvidia-smi` gets the same treatment: that was the remaining driver check, and NVIDIA#1396 closed without landing it. The probe could not tell a GPU that does not support MIG from a query that never ran. Both end up with a non-zero status, and with the query piped into the match, `pipefail` reports the match's status in either case, so an operational failure -- a driver that does not answer, a transient service that could not start -- was silently read as "no MIG here" and the node was reported as converged without ever being looked at. The query is now kept apart from the match so its own status survives: 0 a GPU reports a MIG mode -> configure the node 1 queried fine, no MIG support -> skip the node 2 the query itself failed -> fail, with the reason Exit 2 is only fatal on a node where lspci actually found NVIDIA GPUs, so a node with no NVIDIA hardware still passes through untouched. Two smaller corrections from the same reading: the match accepts only a real MIG mode, since `grep -v N/A` also matched warnings nvidia-smi prints next to the values; and the Red Hat install branch now requires a successful capability probe, which the Debian branch already did. scripts/validation/tests/test_gpu_task_contracts.py covers this. The probe is executed as written against a mocked nvidia-smi and systemd-run, for a failed query (reported on stdout, on stderr, and not at all), an unsupported device, a noisy but successful query, and a repeated run with the device guard already active. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UiFVTVAyEMmn68Xvo9LSTf Signed-off-by: 백지명 <wlaud9805@gmail.com>
|
@dholt thanks — all three points are addressed in MIG administration runs in the transient unit too. A failed query no longer looks like a missing capability. With the query piped straight into the match,
Deliberately stream-independent: nvidia-smi reports a missing device on stdout and a broken driver on stderr, so keying on either one would have been fragile. Two smaller things from the same reading: the match now accepts only a real MIG mode, since The driver check from #1396. Coverage —
I mutation-checked it: reverting to
Noted on the merge commit rather than squash — the branch keeps its three original commits. 🤖 Generated with Claude Code |
dholt
left a comment
There was a problem hiding this comment.
The revision addresses the remaining driver/MIG review points: the administrative operations use the isolated service path and operational query failures no longer silently skip configuration. The 27 validation tests pass in a merge preview with current master, and public CI is green.
Approved. The original contributor commits will be preserved with a merge commit.
Problem
With
slurm_login_on_compute: true,roles/slurm/tasks/login-compute-setup.ymlsetsDeviceAllow=/dev/nvidiactlon 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) andbecomedoes not change that — the device filter is per cgroup, not per user. Every task that runsnvidia-smiafter the guard is applied therefore sees no GPUs:This breaks the second Ansible run that
docs/slurm-cluster/slurm-single-node.mdasks for ("reboot manually when prompted and then run Ansible again"):playbooks/utilities/gpu-clocks.yml—nvidia-smi -acp UNRESTRICTEDallow_user_set_gpu_clocks: yes)playbooks/nvidia-software/nvidia-cuda.yml—test nvidia-smislurm_cluster_install_cuda: yes)playbooks/nvidia-software/nvidia-mig.yml—… | grep -v 'N/A'No devices were found→ treated as a MIG-capable noderoles/nvidia-mig-manager/tasks/main.yml— same probe, same filterplaybooks/utilities/nvidia-set-gpu-clocks.yml—nvidia-smi -lgc/-rgcscripts/validation/validate_slurm.pyalready documents the phenomenon for the validator and usessrunas 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-smiinvocations throughsystemd-run --wait --pipe --collect --quiet. The command executes in a transient unit undersystem.slice, outside the ssh cgroup, so the check still runs for real instead of being skipped. Both MIG probes (playbook and role) now accept onlyEnabled/Disabledand get an explicitbecome: true(the rest of that play/role already requires root). Behaviour on nodes without the guard is unchanged.nvidia-driver.ymlcarries the sametest 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 -acpis 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:
ansible-playbook --syntax-checkpasses for the four playbooks;ansible-lint26.1.1 with the project config reports 0 failures.systemd-run --wait/--pipe/--collectneed systemd ≥ 236, which every supported Ubuntu/RHEL release ships.