You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Distributed training with synchronized SGD using 'grpc+verbs' sometimes hangs indefinitely #11416
I am training a seq2seq model with synchronized SGD (using tf.train.SyncReplicasOptimizer and tf.train.Supervisor), over RDMA (using grpc+verbs protocol), on 2 workers and 1 parameter server. Each worker has 8 GPUs, and the model on each GPU is the same.
I can train this model fine with the default grpc protocol using the same setting. When I switched to grpc+verbs, the behavior becomes unpredictable. Most of the times both workers hang (for at least 12 hours, so not because I didn't wait long enough). Sometimes the chief worker (worker 0) starts training, but worker 1 hangs. (This should not happen since I am programming with synchronized SGD. Worker 0 should be blocked if worker 1 is not ready.) In rare case it can go through and start training. I believe the RDMA driver is correctly installed.
When worker hangs, the CPU utilization stays low but not zero, and the GPU utilization is 0.
Source code / logs
I attached below the log from worker 1 worker1.txt. In this case, worker 1 hangs, and worker 0 starts training. (There are some custom logs printed.) In the log you can find that worker 1 sent a RDMA_MESSAGE_TENSOR_REQUEST to the parameter server, but never got an ACK, and I have checked the log from the parameter server, which showed that it never received a RDMA_MESSAGE_TENSOR_REQUEST from worker 1.
I also attached the full trace gdb_worker1.txt collected on worker 1 in gdb with thread apply all bt, during worker 1 hanging.
@byronyi Thanks for the quick reply. I have tried my code over Ethernet, and it worked fine. I think that should indicate the network fabrics is fine. Also, one experiment I tried over RDMA did go through as I described in the issue. So RDMA fabric seems fine. The loopback mode won't traverse the network stack, right?
Note that RoCE requires a lossless fabric, while gRPC does not. If you could reproduce the error in loopback mode, it would be easier for us to identify the possible issue.
@on-the-run, can u verify the RoCE configuration with ib_write_bw between the 2 nodes ?
As @byronyi said, you may need to configure lossless (PFC) or ECN to prevent the packet loss.
ib_write_bw is a good stress test to see if RoCE is configured good.
Can u attach the full logs of the PS and worker ? I'm missing a lot of events here in the logs.
@shamoya, the RDMA I am using is Infiniband, instead of RoCE. ib_write_bw runs fine. The workers and the parameter sever can talk to each other via RDMA. Posting the output from running ib_write_bw between one worker and one parameter server below.
---------------------------------------------------------------------------------------
RDMA_Write BW Test
Dual-port : OFF Device : mlx4_0
Number of qps : 1 Transport type : IB
Connection type : RC Using SRQ : OFF
CQ Moderation : 100
Mtu : 2048[B]
Link type : IB
Max inline data : 0[B]
rdma_cm QPs : OFF
Data ex. method : Ethernet
---------------------------------------------------------------------------------------
local address: LID 0x15 QPN 0x32da PSN 0xebb028 RKey 0xa0010194 VAddr 0x007f11bbfc2000
remote address: LID 0x12 QPN 0x0337 PSN 0x198251 RKey 0xd001018f VAddr 0x007f728f89f000
---------------------------------------------------------------------------------------
#bytes #iterations BW peak[MB/sec] BW average[MB/sec] MsgRate[Mpps]
65536 5000 6071.23 6071.03 0.097136
---------------------------------------------------------------------------------------
If it's IB then we shouldn't have any packet loss.
VLOG(2) is maybe too much verbose, maybe just change all VLOG in rdma.cc to 0, so we can just see the Rendezvous protocol messages.
How many model parameters are there ?
that's strange. I have not seen issues like that, Your problem probably depends on the ordering of events, which is random. I am wondering if there is memory corruption somewhere.
@junshi15, one thing that I observed to happen repeatedly was that after the RDMA channels have been built, worker 1 sent a RDMA_MESSAGE_TENSOR_REQUEST to PS, and never got an ACK. Then worker 1 was blocked there. And, PS never received that RDMA_MESSAGE_TENSOR_REQUEST . Does this ring a bell?
@shamoya, there are about 70 million parameters. Here are full logs: ps.txt, worker0.txt, worker1.txt
In this case, worker 1 hanged, but worker 0 didn't. Not sure if the log of worker 1 gives enough information. Let me know if you need me to turn on other logs. Thanks.
does distributed tensorflow using 'grpc+verbs' have unit tests? I didn't find any. I meet 2017-07-11 09:46:46.591411: F tensorflow/contrib/verbs/rdma.cc:95] Check failed: cq_ Failed to create completion queue when using 'grpc+verbs' in an ib network.
All the buffers are allocated in system memory, so CUDA8 should not play a role here. My impression is that ibv_reg_mr does pin the memory, although I am not familiar with the source code. @shamoya may be able to explain it.
Maybe I didn't make it clear, I mean the verbs library is not doing nor supposed to do memory pinning in user space: that job is solely done by the in kernel part of your IB driver. Thus you should search it in the kernel source tree and kernel memory pinning API, something like get_user_pages, not the syscall nor user space API like mlock.
@bobzhuyb And I think I have checked with TF people before, and they have made it pretty clear that TF is not designed to utilize UVM nor support this feature. See relevant discussion in here. I also tend to believe neither IB driver or CUDA driver should alter memory mappings managed by the other one, as we are not doing peer memory access for NIC and GPU.
On the other hand I have worked with TF memory allocation subsystem and they are doing a pretty good job on keeping track of CUDA host/device memory allocation. See relevant details for host and device memory. And if you adjust those parameters (like the initial memory allocation or allow_growth=False), you could force it to allocate all CUDA memory at very early stage (before the whole distributed runtime is even initialized). After that, the virtual memory mappings of these memory regions should not be altered. If you do that, the step 2 of your speculation is rather unlikely to happen.
Being said that, the is a possibility that something is wrong in either CUDA or IB driver, but our chances are small. cc @zheng-xq@poxvoculi any comments on this?
I'm having a similar issue with 8 P100 per node (4 nodes), happens with only certain conditions (tf_cnn_script benchmark with "real" data) and the pinning issue is not the case.
I think maybe found the issue (checking now and will report soon).
@byronyi@shamoya Thanks for the clarification. Yes, mlock() was the thing that made it stable in our environment. Good to know that you can reproduce the issue. Please keep us posted.
Hi @on-the-run,
Is there any way to know if the CUDA remaps the memory mapping of the process ?
As said, I feel we see a similar issue, but the mlock workaround doesn't help in our case.
We also feel it's something to do with Pascal memory management (can't say exactly what).
Any clues to what we can check ?
Thanks !
We don't have a concrete evidence. However, we did a basic test -- when we malloc the receiver buffer, we init the buffer with a special value as a signature (say every byte initialized as 0xab). After the successful receive event triggered by WRITE_WITH_IMM, we immediate check the receiver buffer contents. It remains unchanged in TF process.
If you use ibdump at the receiver side, you should see the special signature in the packets. So the data must have arrived. Would you do the same as above to confirm that we are seeing the same (or similar) problem?
There are only two potential explanations,
Receiver NIC didn't DMA the data into the receiver buffer -- we don't see why this may happen
NIC did write the data to physical memory, but the vaddr mapping has changed
To get a concrete evidence, we will need to get the vaddr to physical addr mapping at different stages. Not sure whether the info in /proc/$PID/maps can help us.
@shamoya, unfortunately I am not an expert on CUDA. Also, my colleague @bobzhuyb has taken this issue over. @bobzhuyb, could you give some input when you have time? Thanks!
Hi @bobzhuyb, I made a separate RDMA patch #11392 that supports checksum with VLOG=2. It computes the checksum before sending and after receiving, and the checksum is transmitted out-of-band via gRPC. Maybe you could give it a try and see wether the problem persists.
Activity
on-the-run commentedon Jul 10, 2017
@junshi15 Could you shed some light on this? Thanks!
byronyi commentedon Jul 10, 2017
Have you tried your code in loopback mode? It helps to make sure that the problem doesn't lie in your network fabrics configuration.
on-the-run commentedon Jul 10, 2017
@byronyi Thanks for the quick reply. I have tried my code over Ethernet, and it worked fine. I think that should indicate the network fabrics is fine. Also, one experiment I tried over RDMA did go through as I described in the issue. So RDMA fabric seems fine. The loopback mode won't traverse the network stack, right?
byronyi commentedon Jul 10, 2017
Note that RoCE requires a lossless fabric, while gRPC does not. If you could reproduce the error in loopback mode, it would be easier for us to identify the possible issue.
shamoya commentedon Jul 10, 2017
@on-the-run, can u verify the RoCE configuration with ib_write_bw between the 2 nodes ?
As @byronyi said, you may need to configure lossless (PFC) or ECN to prevent the packet loss.
ib_write_bw is a good stress test to see if RoCE is configured good.
Can u attach the full logs of the PS and worker ? I'm missing a lot of events here in the logs.
on-the-run commentedon Jul 10, 2017
@shamoya, the RDMA I am using is Infiniband, instead of RoCE.
ib_write_bwruns fine. The workers and the parameter sever can talk to each other via RDMA. Posting the output from runningib_write_bwbetween one worker and one parameter server below.on-the-run commentedon Jul 10, 2017
@shamoya, about the logs of PS and worker, I didn't turn on VLOG for the log file I posted earlier. Will a log with VLOG(2) enabled be useful?
shamoya commentedon Jul 10, 2017
If it's IB then we shouldn't have any packet loss.
VLOG(2) is maybe too much verbose, maybe just change all VLOG in rdma.cc to 0, so we can just see the Rendezvous protocol messages.
How many model parameters are there ?
junshi15 commentedon Jul 10, 2017
@on-the-run Did you even run an example successfully, say InceptionV3 training on ImageNet dataset?
on-the-run commentedon Jul 10, 2017
@junshi15, Yes. The same code did go through once on RDMA, and it worked well at that time. I didn't try InceptionV3, though.
junshi15 commentedon Jul 10, 2017
that's strange. I have not seen issues like that, Your problem probably depends on the ordering of events, which is random. I am wondering if there is memory corruption somewhere.
on-the-run commentedon Jul 10, 2017
@junshi15, one thing that I observed to happen repeatedly was that after the RDMA channels have been built, worker 1 sent a
RDMA_MESSAGE_TENSOR_REQUESTto PS, and never got an ACK. Then worker 1 was blocked there. And, PS never received thatRDMA_MESSAGE_TENSOR_REQUEST. Does this ring a bell?on-the-run commentedon Jul 10, 2017
@shamoya, there are about 70 million parameters. Here are full logs:
ps.txt,
worker0.txt,
worker1.txt
In this case, worker 1 hanged, but worker 0 didn't. Not sure if the log of worker 1 gives enough information. Let me know if you need me to turn on other logs. Thanks.
suiyuan2009 commentedon Jul 11, 2017
does distributed tensorflow using 'grpc+verbs' have unit tests? I didn't find any. I meet
2017-07-11 09:46:46.591411: F tensorflow/contrib/verbs/rdma.cc:95] Check failed: cq_ Failed to create completion queuewhen using 'grpc+verbs' in an ib network.42 remaining items
junshi15 commentedon Jul 18, 2017
All the buffers are allocated in system memory, so CUDA8 should not play a role here. My impression is that
ibv_reg_mrdoes pin the memory, although I am not familiar with the source code. @shamoya may be able to explain it.bobzhuyb commentedon Jul 18, 2017
@junshi15 I understand that you only allocate main memory. Nevertheless, CUDA starts after your code, and with Pascal GPUs, it maps GPU memory to the same virtual memory address space as the process (see Unified Memory in https://devblogs.nvidia.com/parallelforall/cuda-8-features-revealed/). We do not know what it does with the existing virtual addr and physical addr mapping.
Otherwise, I don't know how to explain why it works with one GPU, while starts to break with more GPUs..
byronyi commentedon Jul 18, 2017
Maybe I didn't make it clear, I mean the verbs library is not doing nor supposed to do memory pinning in user space: that job is solely done by the in kernel part of your IB driver. Thus you should search it in the kernel source tree and kernel memory pinning API, something like
get_user_pages, not the syscall nor user space API likemlock.byronyi commentedon Jul 19, 2017
@bobzhuyb And I think I have checked with TF people before, and they have made it pretty clear that TF is not designed to utilize UVM nor support this feature. See relevant discussion in here. I also tend to believe neither IB driver or CUDA driver should alter memory mappings managed by the other one, as we are not doing peer memory access for NIC and GPU.
On the other hand I have worked with TF memory allocation subsystem and they are doing a pretty good job on keeping track of CUDA host/device memory allocation. See relevant details for host and device memory. And if you adjust those parameters (like the initial memory allocation or
allow_growth=False), you could force it to allocate all CUDA memory at very early stage (before the whole distributed runtime is even initialized). After that, the virtual memory mappings of these memory regions should not be altered. If you do that, the step 2 of your speculation is rather unlikely to happen.Being said that, the is a possibility that something is wrong in either CUDA or IB driver, but our chances are small. cc @zheng-xq @poxvoculi any comments on this?
shamoya commentedon Jul 19, 2017
@on-the-run @bobzhuyb, the assumption doesn't make sense to me.
The memory is being pinned in https://github.com/torvalds/linux/blob/master/drivers/infiniband/core/umem.c#L83 , which is executed in the ibv_reg_mr flow, so mlcok shouldn't have any effect.
Also as @byronyi (this is what I know as well) said, TF doesn't support UVM.
Are u sure this is the only thing u changed that fixed the bug ?
I'm having a similar issue with 8 P100 per node (4 nodes), happens with only certain conditions (tf_cnn_script benchmark with "real" data) and the pinning issue is not the case.
I think maybe found the issue (checking now and will report soon).
bobzhuyb commentedon Jul 19, 2017
@byronyi @shamoya Thanks for the clarification. Yes, mlock() was the thing that made it stable in our environment. Good to know that you can reproduce the issue. Please keep us posted.
shamoya commentedon Jul 24, 2017
Hi @bobzhuyb,
The mlock solution still doesn't make sense to me.
it shouldn't have any effect, unless you a severe driver issues.
Can u involve RDMA community in this issue in https://github.com/linux-rdma/rdma-core ?
Anyway my issue still not solved, I opened an issue in #11725.
Any help is appreciated, if u can take a look.
@junshi15 @byronyi if u have time I would be delighted as well.
shamoya commentedon Aug 7, 2017
Hi @on-the-run,
Is there any way to know if the CUDA remaps the memory mapping of the process ?
As said, I feel we see a similar issue, but the mlock workaround doesn't help in our case.
We also feel it's something to do with Pascal memory management (can't say exactly what).
Any clues to what we can check ?
Thanks !
junshi15 commentedon Aug 7, 2017
I was using K80 and CUDA-7.5, and was able to reproduce the other issue (#11725). So at least that issue is not only limited to Pascal.
bobzhuyb commentedon Aug 7, 2017
We don't have a concrete evidence. However, we did a basic test -- when we malloc the receiver buffer, we init the buffer with a special value as a signature (say every byte initialized as 0xab). After the successful receive event triggered by WRITE_WITH_IMM, we immediate check the receiver buffer contents. It remains unchanged in TF process.
If you use ibdump at the receiver side, you should see the special signature in the packets. So the data must have arrived. Would you do the same as above to confirm that we are seeing the same (or similar) problem?
There are only two potential explanations,
To get a concrete evidence, we will need to get the vaddr to physical addr mapping at different stages. Not sure whether the info in /proc/$PID/maps can help us.
on-the-run commentedon Aug 7, 2017
@shamoya, unfortunately I am not an expert on CUDA. Also, my colleague @bobzhuyb has taken this issue over. @bobzhuyb, could you give some input when you have time? Thanks!
byronyi commentedon Aug 8, 2017
Hi @bobzhuyb, I made a separate RDMA patch #11392 that supports checksum with VLOG=2. It computes the checksum before sending and after receiving, and the checksum is transmitted out-of-band via gRPC. Maybe you could give it a try and see wether the problem persists.
tensorflowbutler commentedon Dec 20, 2017
It has been 14 days with no activity and this issue has an assignee.Please update the label and/or status accordingly.
on-the-run commentedon Dec 20, 2017
Closed due to inactivity. Please reopen the issue if you have updates or resolved the issue. Thanks.