From 2aee70cbfd4209cd79ef90c5a6634dc967f5007e Mon Sep 17 00:00:00 2001 From: Chris Hines <chris.hines@monash.edu> Date: Thu, 23 Feb 2017 12:41:01 +1100 Subject: [PATCH] better template for gres.conf allowing for Grid K1 GPUS and different CPU counts --- roles/slurm-common/files/scripts/nvidia-probe.py | 2 +- roles/slurm-common/tasks/main.yml | 5 +++++ roles/slurm-common/templates/gres.conf.j2 | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/slurm-common/files/scripts/nvidia-probe.py b/roles/slurm-common/files/scripts/nvidia-probe.py index 4b3e93e1..ba23982e 100755 --- a/roles/slurm-common/files/scripts/nvidia-probe.py +++ b/roles/slurm-common/files/scripts/nvidia-probe.py @@ -35,7 +35,7 @@ try: if not line : break #print "Line is ",line - pe=re.compile('GPU\s*(\d*).*Tesla\s*(\S*)') + pe=re.compile('GPU\s+(\d*):\s+\S+\s+(\S*)') m=pe.search(line) if not m: #print "No match found" diff --git a/roles/slurm-common/tasks/main.yml b/roles/slurm-common/tasks/main.yml index 2e414650..d99cb2ff 100644 --- a/roles/slurm-common/tasks/main.yml +++ b/roles/slurm-common/tasks/main.yml @@ -90,6 +90,11 @@ register: probeOutput check_mode: no +- name: get cpu count + shell: 'lscpu | grep "On-line CPU" | cut -f 2 -d ":" | sed "s/\ *//g"' + register: cpucount + check_mode: no + - name: "set nvidiaprobe slurm_gres_list" set_fact: "slurm_gres_list={{ probeOutput.stdout }}" diff --git a/roles/slurm-common/templates/gres.conf.j2 b/roles/slurm-common/templates/gres.conf.j2 index 24001d0d..9d13ec66 100644 --- a/roles/slurm-common/templates/gres.conf.j2 +++ b/roles/slurm-common/templates/gres.conf.j2 @@ -1,5 +1,5 @@ #slurm gres file for {{ ansible_hostname }} #No Of Devices={{ slurm_gres_list | length }} {% for gr in slurm_gres_list %} -Name={{ gr.name }} Type={{ gr.type }} File={{ gr.file }} CPUs=0-23 +Name={{ gr.name }} Type={{ gr.type }} File={{ gr.file }} CPUs={{ cpucount.stdout }} {% endfor %} -- GitLab