Skip to content

Commit 839904f

Browse files
committed
feat(example): add slurm module reference YAMLs
Adds two ci-demo example matrix files for the slurm module: - job_matrix_slurm.yaml: agent-based example showing the full Slurm job lifecycle (allocation, run, stopAllForBuild). - job_matrix_slurm_k8.yaml: Kubernetes variant running Slurm module steps inside a k8s pod with a PVC for job ID persistence. Signed-off-by: Daniel Pressler <danielpr@nvidia.com>
1 parent ac447b9 commit 839904f

2 files changed

Lines changed: 138 additions & 0 deletions

File tree

.ci/examples/job_matrix_slurm.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
job: slurm-example
3+
4+
# Slurm head node and job configuration — set these as Jenkins env vars or override here.
5+
env:
6+
SLURM_HEAD_NODE: scctl
7+
SLURM_PARTITION: gpu
8+
SLURM_NODES: '1'
9+
SLURM_JOB_TIMEOUT: '01:00:00'
10+
DOCKER_IMAGE: 'ubuntu:22.04'
11+
SLURM_JOB_ID_DIR: '/tmp'
12+
SLURM_JOB_ID_FILE: '/tmp/job_id_${BUILD_NUMBER}.txt'
13+
# SCCTL_CREDENTIALS_ID must be set to a Jenkins username/password credential id
14+
# when SLURM_HEAD_NODE is 'scctl'.
15+
16+
runs_on_agents:
17+
- {nodeLabel: master}
18+
19+
# Allocate Slurm nodes before steps run.
20+
# credentialsId is required when headNode is 'scctl'.
21+
pipeline_start:
22+
shell: action
23+
module: slurmCI
24+
run: allocation
25+
args:
26+
partition: '${SLURM_PARTITION}'
27+
headNode: '${SLURM_HEAD_NODE}'
28+
nodes: '${SLURM_NODES}'
29+
jobTimeout: '${SLURM_JOB_TIMEOUT}'
30+
jobIdFile: '${SLURM_JOB_ID_FILE}'
31+
credentialsId: '${SCCTL_CREDENTIALS_ID}'
32+
33+
steps:
34+
# Read the job ID written by allocation() into a Jenkins env var so
35+
# subsequent slurm.run() steps can reference it as ${SLURM_JOB_ID}.
36+
- name: Read Slurm job ID
37+
shell: action
38+
module: groovy
39+
run: env.SLURM_JOB_ID = readFile(env.SLURM_JOB_ID_FILE).trim()
40+
41+
- name: Run test script
42+
shell: action
43+
module: slurmCI
44+
run: run
45+
args:
46+
jobId: '${SLURM_JOB_ID}'
47+
headNode: '${SLURM_HEAD_NODE}'
48+
testScript: 'echo "Hello from Slurm node $(hostname)"'
49+
dockerImage: '${DOCKER_IMAGE}'
50+
nodes: '${SLURM_NODES}'
51+
52+
# Cancel all allocations for this build on completion (success or failure).
53+
pipeline_stop:
54+
shell: action
55+
module: slurmCI
56+
run: stopAllForBuild
57+
args:
58+
headNode: '${SLURM_HEAD_NODE}'
59+
jobIdDir: '${SLURM_JOB_ID_DIR}'
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
job: slurm-k8-example
3+
4+
kubernetes:
5+
cloud: swx-k8s
6+
namespace: default
7+
limits: "{memory: 1Gi, cpu: 500m}"
8+
requests: "{memory: 256Mi, cpu: 250m}"
9+
10+
# for step persistance job id file location
11+
pvc_volumes:
12+
- {claimName: nbu-swx-pvc, mountPath: /mnt/pvc, readOnly: false}
13+
14+
empty_volumes:
15+
- {mountPath: /root, memory: false}
16+
17+
# Slurm head node and job configuration — set these as Jenkins env vars or override here.
18+
env:
19+
SLURM_HEAD_NODE: headnode
20+
SLURM_PARTITION: gpu
21+
SLURM_NODES: '1'
22+
SLURM_GRES: "gpu:1"
23+
SLURM_JOB_TIMEOUT: '01:00:00'
24+
DOCKER_IMAGE: 'ubuntu:22.04'
25+
SLURM_JOB_ID_DIR: '/mnt/pvc'
26+
SLURM_JOB_ID_FILE: '/mnt/pvc/job_id_${BUILD_NUMBER}.txt'
27+
# CREDENTIALS_ID: must be set to a Jenkins ssh key credential id with access to the Slurm head node.
28+
29+
# when using scctl use docker image with scctl client installed, otherwise use any image that matches the architecture of the Slurm nodes
30+
runs_on_dockers:
31+
- {name: "ubuntu-x86_64", url: "ubuntu:22.04", arch: "x86_64"}
32+
33+
steps:
34+
- name: Allocate Slurm nodes
35+
shell: action
36+
module: slurmCI
37+
run: allocation
38+
args:
39+
headNode: '${SLURM_HEAD_NODE}'
40+
partition: '${SLURM_PARTITION}'
41+
nodes: '${SLURM_NODES}'
42+
timeout: '${SLURM_JOB_TIMEOUT}'
43+
jobIdFile: '${SLURM_JOB_ID_FILE}'
44+
credentialsId: '${CREDENTIALS_ID}'
45+
extraArgs: [
46+
"--gres=${SLURM_GRES}",
47+
]
48+
49+
# Read the job ID written by allocation() into a Jenkins env var so
50+
# subsequent slurm.run() steps can reference it as ${SLURM_JOB_ID}.
51+
- name: Read Slurm job ID
52+
shell: action
53+
module: groovy
54+
run: env.SLURM_JOB_ID = readFile(env.SLURM_JOB_ID_FILE).trim()
55+
56+
- name: Run test script
57+
shell: action
58+
module: slurmCI
59+
run: run
60+
args:
61+
jobId: '${SLURM_JOB_ID}'
62+
headNode: '${SLURM_HEAD_NODE}'
63+
testScript: 'env | grep SLURM'
64+
dockerImage: '${DOCKER_IMAGE}'
65+
credentialsId: '${CREDENTIALS_ID}'
66+
nodes: '${SLURM_NODES}'
67+
slurmEnv: [
68+
"SLURM_TEST_VAR=hello_slurm"
69+
]
70+
71+
# Cancel all allocations for this build on completion (success or failure).
72+
pipeline_stop:
73+
shell: action
74+
module: slurmCI
75+
run: stop
76+
args:
77+
credentialsId: '${CREDENTIALS_ID}'
78+
headNode: '${SLURM_HEAD_NODE}'
79+
jobId: '${SLURM_JOB_ID}'

0 commit comments

Comments
 (0)