Ticket 2766

Summary: GPU binding problem, reported by NVIDIA
Product: Slurm Reporter: Moe Jette <jette>
Component: SchedulingAssignee: Moe Jette <jette>
Status: RESOLVED CANNOTREPRODUCE QA Contact:
Severity: 3 - Medium Impact    
Priority: --- CC: bbbbbbbbrie, kilian
Version: 16.05.x   
Hardware: Linux   
OS: Linux   
Site: SchedMD Slinky Site: ---
Alineos Sites: --- Atos/Eviden Sites: ---
Confidential Site: --- Coreweave sites: ---
Cray Sites: --- DS9 clusters: ---
Google sites: --- HPCnow Sites: ---
HPE Sites: --- IBM Sites: ---
NOAA SIte: --- NoveTech Sites: ---
Nvidia HWinf-CS Sites: --- OCF Sites: ---
Recursion Pharma Sites: --- SFW Sites: ---
SNIC sites: --- Tzag Elita Sites: ---
Linux Distro: --- Machine Name:
CLE Version: Version Fixed: 16.05.0
Target Release: --- DevPrio: ---
Emory-Cloud Sites: ---
Attachments: slurm.conf file
gres.conf file

Description Moe Jette 2016-05-24 09:28:23 MDT
Hi Jacob,


We're having a bit of trouble with the flag. Users are complaining that their jobs won't run. I've explained to them that the topology could easily block their jobs, especially if not all jobs use the binding flag. However I'm seeing some inconsistent results with respect to affinity and also some crashes. Is there something I'm missing? Do we need to specify a certain number of CPUs or sockets?


slurm.conf definition is here:


NodeName=vca0[1-8],vca09,vca10 Gres=gpu:8 Sockets=2 CoresPerSocket=20 ThreadsPerCore=1 CPUs=40 RealMemory=257929 TmpDisk=64000 State=UNKNOWN​


If I create a reservation on a node so that there are no other jobs running, my jobs run with the flag (these jobs where run simultaneously and stayed running)

dholt@dl4all:~$ srun -w vca02 --reservation=dholt_11 --gres=gpu:3 --gres-flags=enforce-binding ~/foo
        GPU0    GPU1    GPU2    CPU Affinity
GPU0     X      PIX     PHB     0-0
GPU1    PIX      X      PHB     0-0
GPU2    PHB     PHB      X      0-0

dholt@dl4all:~$ srun -w vca02 --reservation=dholt_11 --gres=gpu:3 --gres-flags=enforce-binding ~/foo
        GPU0    GPU1    GPU2    CPU Affinity
GPU0     X      SOC     SOC     20-20
GPU1    SOC      X      PIX     20-20
GPU2    SOC     PIX      X      20-20

dholt@dl4all:~$ srun -w vca02 --reservation=dholt_11 --gres=gpu:2 --gres-flags=enforce-binding ~/foo
        GPU0    GPU1    CPU Affinity
GPU0     X      PIX     5-5
GPU1    PIX      X      5-5


The affinity above also does not look correct, assuming nvidia-smi is doing the right thing.


I can also crash Slurm by specifying CPUs/job:


dholt@dl4all:~$ srun -w vca02 --reservation=dholt_11 --gres=gpu:8 --gres-flags=enforce-binding --accel-bind=g -c 4 --pty bash -i
srun: error: slurm_receive_msg: Zero Bytes were transmitted or received
srun: error: Unable to allocate resources: Zero Bytes were transmitted or received

May 23 13:30:56 dl4all kernel: [582274.216576] slurmctld_srvcn[27751]: segfault at 1400000018 ip 00007f1aee2b08f3 sp 00007f1ae9f42f50 error 4 in libc-2.19.so[7f1aee232000+1bb000]


dholt@dl4all:~$ srun -w vca02 --reservation=dholt_11 --gres=gpu:8 --gres-flags=enforce-binding -c2 nvidia-smi topo -m
srun: error: slurm_receive_msg: Zero Bytes were transmitted or received
srun: error: Unable to allocate resources: Zero Bytes were transmitted or received
dholt@dl4all:~$ ps -ef | grep slurm
slurm     1701     1  0 May17 ?        00:00:06 /usr/local/sbin/slurmdbd slurm
dholt    19440 13513  0 14:01 pts/3    00:00:00 grep slurm

[582222.442612] slurmctld_srvcn[26992]: segfault at 5a ip 00007fb698140845 sp 00007fb68f5f3e50 error 4 in libc-2.19.so[7fb6980c2000+1bb000]
[582274.216576] slurmctld_srvcn[27751]: segfault at 1400000018 ip 00007f1aee2b08f3 sp 00007f1ae9f42f50 error 4 in libc-2.19.so[7f1aee232000+1bb000]
[584106.976915] slurmctld_srvcn[19432]: segfault at 5a ip 00007f4e006fd845 sp 00007f4de74f2e50 error 4 in libc-2.19.so[7f4e0067f000+1bb000]
Comment 1 Moe Jette 2016-05-24 09:29:29 MDT
Created attachment 3135 [details]
slurm.conf file
Comment 2 Moe Jette 2016-05-24 09:29:49 MDT
Created attachment 3136 [details]
gres.conf file
Comment 3 Moe Jette 2016-05-25 04:33:17 MDT
Fix for invalid memory reference/abort here:
https://github.com/SchedMD/slurm/commit/ba43d2f3659e1eb2accdae8e21287f70ab872937
Comment 4 Moe Jette 2016-06-01 02:26:01 MDT
We released Slurm version 16.05.0 on Tuesday 31 May. That release includes a fix for the reported slurmctld daemon abort and a couple of other relevant bug fixes. I have appended excerpts of my configuration files and some job logs.

Note that Slurm can support heterogeneous clusters with various processor types in the same resource pool, so it requires a consistent CPU ID numbering system (all of the CPUs/threads within a single core are consecutive and all of the CPUs/threads within a single socket are consecutive. See the gres.conf man page for more information (http://slurm.schedmd.com/gres.conf.html).

# Excerpt from slurm.conf
GresTypes=gpu
NodeName=smd-server CPUs=24 Sockets=2 CoresPerSocket=6 ThreadsPerCore=2 RealMemory=7960 TmpDisk=505487 State=UNKNOWN GRES=gpu:4


# gres.conf
Name=gpu File=/dev/tty0 CPUs=0-11
Name=gpu File=/dev/tty1 CPUs=0-11
Name=gpu File=/dev/tty2 CPUs=12-23
Name=gpu File=/dev/tty3 CPUs=12-23


# Job 1, allocated socket 0, core 0, GPU 0
$ srun --gres=gpu:1 -n1  --gres-flags=enforce-binding --cpu_bind=v tmp
cpu_bind=MASK - smd-server, task  0  0 [16729]: mask 0x1001 set
CUDA_VISIBLE_DEVICES=0
slurmctld: ====================
slurmctld: job_id:8143 nhosts:1 ncpus:1 node_req:1 nodes=smd-server
slurmctld: Node[0]:
slurmctld:   Mem(MB):100:0  Sockets:2  Cores:6  CPUs:2:0
slurmctld:   Socket[0] Core[0] is allocated


# Job 2, allocated socket 1, core 0, GPU 2
$ srun --gres=gpu:1 -n1  --gres-flags=enforce-binding --cpu_bind=v tmp
cpu_bind=MASK - smd-server, task  0  0 [16850]: mask 0x2002 set
CUDA_VISIBLE_DEVICES=2
slurmctld: ====================
slurmctld: job_id:8144 nhosts:1 ncpus:1 node_req:1 nodes=smd-server
slurmctld: Node[0]:
slurmctld:   Mem(MB):100:0  Sockets:2  Cores:6  CPUs:2:0
slurmctld:   Socket[1] Core[0] is allocated


# Job 3 WITHOUT --gres-flags=enforce-binding
# Allocated socket 0, core 1 GPUs 1 & 3, SPLIT ACROSS SOCKETS
$ srun --gres=gpu:2 -n1 --cpu_bind=v tmp
cpu_bind=MASK - smd-server, task  0  0 [17033]: mask 0x4004 set
CUDA_VISIBLE_DEVICES=1,3
urmctld: ====================
slurmctld: job_id:8145 nhosts:1 ncpus:1 node_req:1 nodes=smd-server
slurmctld: Node[0]:
slurmctld:   Mem(MB):100:0  Sockets:2  Cores:6  CPUs:2:0
slurmctld:   Socket[0] Core[1] is allocated


# Job 4 WITH --gres-flags=enforce-binding
# Job hangs until job 1 or 2 end to avoid splitting across sockets
$ srun --gres=gpu:2 -n1 --gres-flags=enforce-binding --cpu_bind=v tmp
srun: job 8153 queued and waiting for resources
srun: job 8153 has been allocated resources
cpu_bind=MASK - smd-server, task  0  0 [17639]: mask 0x2002 set
CUDA_VISIBLE_DEVICES=2,3
slurmctld: ====================
slurmctld: job_id:8153 nhosts:1 ncpus:1 node_req:1 nodes=smd-server
slurmctld: Node[0]:
slurmctld:   Mem(MB):100:0  Sockets:2  Cores:6  CPUs:2:0
slurmctld:   Socket[1] Core[0] is allocated


# Job 5 WITH --gres-flags=enforce-binding AND multiple tasks
# Specify --ntasks-per-socket to confine allocation to specific socket count
# Job hangs until job 1 or 2 end to avoid splitting across sockets
$ srun --gres=gpu:2 -n4 --ntasks-per-socket=4 --gres-flags=enforce-binding --cpu_bind=v tmp
srun: job 8156 queued and waiting for resources
srun: job 8156 has been allocated resources
cpu_bind=MASK - smd-server, task  1  1 [17882]: mask 0xa00a set
cpu_bind=MASK - smd-server, task  3  3 [17884]: mask 0xa00a set
cpu_bind=MASK - smd-server, task  0  0 [17881]: mask 0xa00a set
cpu_bind=MASK - smd-server, task  2  2 [17883]: mask 0xa00a set
CUDA_VISIBLE_DEVICES=2,3
CUDA_VISIBLE_DEVICES=2,3
CUDA_VISIBLE_DEVICES=2,3
CUDA_VISIBLE_DEVICES=2,3
slurmctld: ====================
slurmctld: job_id:8156 nhosts:1 ncpus:4 node_req:1 nodes=smd-server
slurmctld: Node[0]:
slurmctld:   Mem(MB):200:0  Sockets:2  Cores:6  CPUs:4:0
slurmctld:   Socket[1] Core[0] is allocated
slurmctld:   Socket[1] Core[1] is allocated
Comment 5 Moe Jette 2016-06-02 08:59:01 MDT
Feedback Kilian Cavalotti (Stanford), bug 1725, comment #27
https://bugs.schedmd.com/show_bug.cgi?id=1725#c27

> Hi Moe, 
> 
> I'm happy to report that we tested the --gres-flags=enforce-bindings option in
> 16.05 and that is works exactly as expected.
> 
> Thanks so much for your work on this.
Comment 6 Moe Jette 2016-06-14 04:42:08 MDT
The invalid memory reference problem was fixed as described in comment #3.
I believe the remaining issues were due to a bad configuration and Stanford reports that Slurm is scheduling as desired (comment #5).
I'm closing this unless I get more information to the contrary.
Comment 8 Moe Jette 2016-06-27 11:04:49 MDT
I've tried for hours to reproduce this with a multitude of configurations and scenarios. It would have been nice to see the history of the jobs recovered when slurmctld restarted, but I presume that does not exist, at least with respect to the DebugFlags=gres detailed logging.

Could you configure "DebubFlags=gres,cpu_bind" in slurm.conf and try to reproduce starting from a clean state (start slurmctld with the "-c" option) and capturing the log from that point?

One more thing, I see an advance reservation in the log. What
exactly does that look like (run "scontrol show res") and are you submitting the jobs to run in that reservation or now (e.g. "sbatch --reservation=dhold_10 ..."). Unless you explicitly request use of an advanced reservation and have permission to use it, those resources are off limits to the job.

[2016-06-20T09:23:27.532] Recovered state of reservation dholt_10
[2016-06-20T09:23:27.533] Recovered state of 1 reservations
Comment 9 Moe Jette 2016-07-08 10:53:29 MDT
This functionality seems to be working reliably for me and Stanford.
I'm not hearing anything back from NVIDIA.
Closing unless/until I get more information.