Skip to content

Commit 3e1a127

Browse files
Call nvidia-ctk cdi generate on apply-exit hook
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 93a1e91 commit 3e1a127

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

deployments/systemd/hooks-default.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ hooks:
1616
- workdir: "/etc/nvidia-mig-manager"
1717
command: "/bin/bash"
1818
args: ["-x", "-c", "source hooks.sh; apply-exit"]
19+
- workdir: "/etc/nvidia-mig-manager"
20+
command: "/bin/bash"
21+
args: ["-x", "-c", "source hooks.sh; refresh-cdi"]

deployments/systemd/hooks.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,15 @@ function stop_k8s_pods() {
122122
fi
123123
return 0
124124
}
125+
126+
# refresh-cdi triggers the nvidia-cdi-refresh service to regenerate CDI
127+
# specifications, making updated GPU devices available to container runtimes.
128+
function refresh-cdi() {
129+
# Check if nvidia-cdi-refresh.service exists
130+
if systemctl list-unit-files nvidia-cdi-refresh.service --quiet; then
131+
echo "Found nvidia-cdi-refresh.service, calling systemctl..." >&2
132+
if ! systemctl restart nvidia-cdi-refresh.service; then
133+
echo "Error: Failed to start nvidia-cdi-refresh.service" >&2
134+
fi
135+
fi
136+
}

0 commit comments

Comments
 (0)