Skip to content

tf_cnn_benchmarks.py stuck when running with multiple GPUs and ImageNet data with protocol grpc+verbs #11725

Closed

Description

@shamoya

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No, running tf_cnn_benchmarks.py from benchmarks repo
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 16.04.2 LTS
  • TensorFlow installed from (source or binary): Unmodified source with RDMA Verbs enabled
  • TensorFlow version (use command below): 1.3.0-rc0
  • Python version: 2.7.12
  • Bazel version (if compiling from source): 0.5.1
  • CUDA/cuDNN version: 8.0/6
  • GPU model and memory: NVIDIA Tesla P100 PCIe 16GB (8 per node)
  • Exact command to reproduce:

PS: CUDA_VISIBLE_DEVICES='' python tf_cnn_benchmarks.py --ps_hosts 12.12.12.43:20000 --worker_hosts 12.12.12.44:20000,12.12.12.41:20000 --batch_size=64 --model=inception3 --variable_update=parameter_server --local_parameter_device=cpu --job_name=ps --task_index=0 --server_protocol grpc+verbs

Worker0: CUDA_VISIBLE_DEVICES='0,1,2,3,4,5,6,7' python tf_cnn_benchmarks.py --ps_hosts 12.12.12.43:20000 --worker_hosts 12.12.12.44:20000,12.12.12.41:20000 --batch_size=64 --model=inception3 --variable_update=parameter_server --local_parameter_device=cpu --job_name=worker --task_index=0 --num_gpus=8 --data_dir=/data/imagenet_data/ --train_dir=/data/imagenet_train/ --server_protocol grpc+verbs

Worker1: CUDA_VISIBLE_DEVICES='0,1,2,3,4,5,6,7' python tf_cnn_benchmarks.py --ps_hosts 12.12.12.43:20000 --worker_hosts 12.12.12.44:20000,12.12.12.41:20000 --batch_size=64 --model=inception3 --variable_update=parameter_server --local_parameter_device=cpu --job_name=worker --task_index=1 --num_gpus=8 --data_dir=/data/imagenet_data/ --train_dir=/data/imagenet_train/ --server_protocol grpc+verbs

  • RDMA driver version: MLNX_OFED_LINUX-4.1-1.0.2.0

Describe the problem

When running the above commands (Inception V3 synchronized data parallelism training with 2 workers and 1 external ps), the tf_cnn_benchmarks application hangs forever after some iterations (usually in warm up).

It happens only when real data is involved (ImageNet), and with >4 GPUs. (More GPUs, less iterations before it hangs). Doesn't happen with grpc protocol, or when running with "synthetic" data.

The master_service in the workers is stuck here, which I guess means some operations in the computation have not been completed.

The RDMA protocol looks valid and clean, all messages corresponds to the protocol (see below logs).
There some tensors requested by the workers which they don't receive, but they are passed by the RDMA Verbs transport to the BaseRendezvoudMgr with RecvLocalAsync in a valid way, and for some reason the higher level worker service doesn't trigger the Send kernel on those tensors.

Any help is much appreciated!
If there are some debug mechanisms I can use to understand which tensors/operations have not been completed it can greatly help. I was mostly debugging this from the RDMA Verbs layer till now, without much success, and I feel I don't have enough information there to understand what's missing.
Also I feel we don't have enough knowledge on how the step_id acts (diving into this in the code now, but there's some higher level documentation it can greatly help).

My initial guess was an occurrence of a racy condition when loading the data, since it creates a gap in execution time (worker0 starts the first training step 30-60 seconds after worker1, since it does the preprocessing of the data twice for a reason I couldn't understand yet), but after the first iteration (which usually passes successfully) the time is synchronized between workers.

Source code / logs

Those are the logs of the runtime after moving the logging in rdma.cc to VLOG(0) (also adding Tensor name and step id for all cases, in some cases the step_id doesn't mean anything like BUFFER_REQUEST/RESPONSE for example), and also some VLOG in master_session.cc

worker0
worker1
ps

Unfortunately they are fairly large, but it's better then to cut the log files IMO.
Example for analysis I did in the verbs layer, comparing the Sent Tensor requests to the actual received tensors writes in both workers:

worker 0:

  • /job:ps/replica:0/task:0/cpu:0;f3c10d28b54074c0;/job:worker/replica:0/task:0/gpu:0;edge_116943_group_deps_2/NoOp_1;0:0 80661058974090965
  • /job:worker/replica:0/task:1/cpu:0;1a50d5c51cd9c5d1;/job:worker/replica:0/task:0/gpu:0;edge_116947_group_deps_3/NoOp_1;0:0 80661058974090965
  • /job:worker/replica:0/task:1/gpu:2;7f00fadabfe781f5;/job:worker/replica:0/task:0/gpu:0;edge_111078_group_deps_1/NoOp_2;0:0 80661058974090965
  • /job:worker/replica:0/task:1/gpu:4;b07185dd19f62088;/job:worker/replica:0/task:0/gpu:0;edge_111080_group_deps_1/NoOp_4;0:0 80661058974090965

worker 1:

  • /job:ps/replica:0/task:0/cpu:0;f3c10d28b54074c0;/job:worker/replica:0/task:1/cpu:0;edge_155113_AssignAdd;0:0 80661058974090965
  • /job:worker/replica:0/task:0/gpu:0;f3df8abf03739fe8;/job:worker/replica:0/task:1/cpu:0;edge_116948_group_deps_3;0:0 80661058974090965

The tensors requests received well by the other side and passed to RecvLocalAsync, but are not called later.

Thanks a lot.

Activity

  1. junshi15 commented on Jul 24, 2017

    @junshi15
    Contributor

    I was able to reproduce the issue. I also tried 'alexnet', it hung as well. I will take a close look in the coming days. Thanks for reporting.

  2. added
    stat:contribution welcome
    on Jul 25, 2017
  3. reedwm commented on Jul 25, 2017

    @reedwm
    Contributor

    Thank you for looking into this @junshi15!

  4. shamoya commented on Jul 25, 2017

    @shamoya
    ContributorAuthor

    @mrry @jhseu @poxvoculi , just a small question.
    I'm trying to understand why execution hangs in here.
    What (I think) I need is to get the Executor(s) which doesn't end in here.
    I tried passing tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE) to sess.run but then I get a huge file I can't really understand. Is this the right way ?

  5. suiyuan2009 commented on Jul 25, 2017

    @suiyuan2009
    Contributor

    I have met stuck problem(I think it may happen in warm up if I'm right.) when all workers finished all steps. I think global_step should be protected by a lock.I raised an issue. I'm not sure if tensorflow has some special code for global_step.

  6. assigned and unassigned on Jul 25, 2017
  7. poxvoculi commented on Jul 25, 2017

    @poxvoculi
    Contributor
  8. reedwm commented on Jul 25, 2017

    @reedwm
    Contributor

    @tfboyd I'm unassigning myself because I know very little about the RPC layer and know nothing about VERBs. I don't think this is a bug with tf_cnn_benchmarks, because #11416 also has the same issue with a different model.

    @suiyuan2009 I don't think tensorflow/benchmarks#38 is the same issue, since this issue only occurs with verbs, and it occurs with another model with verbs. I'll take a look at tensorflow/benchmarks#38 though.

  9. removed their assignment
    on Jul 25, 2017
  10. shamoya commented on Jul 26, 2017

    @shamoya
    ContributorAuthor

    Thanks @poxvoculi
    Sadly the smallest case which repro the issue is 3 nodes (2 workers 1 ps) with InveptionV3 and ImageNet, with the tf_cnn_benchmark.py (haven't checked others).
    I had ~15 hypotheses which turn out to be false.
    Added a lot of prints, but still couldn't understand which tensor is the rebel.
    I feel the trace_log mechanism (tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)) can help me here, but I have no idea how to parse it. Is there a parsing tool or format for it ?

  11. suiyuan2009 commented on Jul 26, 2017

    @suiyuan2009
    Contributor

    after adding a lock to global step, I didn't meet stuck problem.
    but I got error when running vgg benchmark code, maybe my network environment is a little unstable.

    2017-07-26 21:21:26.691844: F tensorflow/contrib/verbs/rdma.cc:683] Check failed: status.ok() RecvLocalAsync was not ok, key/job:worker/replica:0/task:2/gpu:1;b0903effc6e4881e;/job:ps/replica:0/task:0/cpu:0;edge_2493_Mul_1;0:0;138139939197237012 error message: Step 138139939197237012
    
  12. byronyi commented on Jul 26, 2017

    @byronyi
    Contributor

    @suiyuan2009 Your error might be caused by another process (PS or worker) in your job. We have met the same problem and it turns out when one process terminated the connection, its peers will print out such odd error log.

  13. 35 remaining items

  14. yanivbl6 commented on Aug 10, 2017

    @yanivbl6

    I think this line relate to the condition variable of "Notification n", which requires a mutex. (for waiting).
    If I got this right The condition variable is waiting for the callback, that was scheduled after the stream in ThenExecute.

  15. yanivbl6 commented on Aug 14, 2017

    @yanivbl6

    I think the problem rises because the Sync deviceToDevice operation blocks the thread, preventing the earlier Async Device to Device operation from finishing- which, for some reason, blocks the later operation.

    What I did to check this was change the call to the wrapper sync function to a call to the async function, and inserted the rest of the code (that which is executed after the sync wrapper) into then lambda callback function ("done"). With this setting, the application no longer hangs (Tested multipile times, few of which in 8 gpus system).
    @junshi15 , is there an additional motivation for the usage of the sync wrappers, beside the pending operations we execute after the operation is completed?

  16. junshi15 commented on Aug 14, 2017

    @junshi15
    Contributor

    @yanivbl6 Thanks for looking into it. There is another sync wrapper function, SetProtoFromGPUSync. We should convert that back to async as well.

    The motivation for using sync wrapper is mainly for simplicity. Otherwise, you end up with chained call-backs, which is actually fairly common in tensorflow code.

    Please submit a PR if you have a fix.

  17. shamoya commented on Aug 15, 2017

    @shamoya
    ContributorAuthor

    Great job @yanivbl6 , looks like this is it.
    Waiting for the PR with the fix.

    Looking now in the gRPC code, they are doing this flow aysnc, this is probably why we didn't see it when running with gRPC.

  18. bkovalev commented on Aug 15, 2017

    @bkovalev

    Thanks to all to solve it! Great job! Go to check it !
    Need to put it in r1.3 and master.

  19. junshi15 commented on Aug 17, 2017

    @junshi15
    Contributor

    @poxvoculi We found some of the wrapper functions caused hang. Do you know whether we are not supposed to use the sync version of these functions? I know CPU/GPU transfer can be slow, but I did not expect it to hang. Thanks.

  20. poxvoculi commented on Aug 17, 2017

    @poxvoculi
    Contributor

    I would avoid using any sync version of a function where an async version with callback is available. The sync versions suspend a thread which could lead to a deadlock if you run out of threads. It may be that by blocking you've also introduced a deadlock some other way, where the callback is waiting on something whose execution would have been triggered after the async invocation returned.

  21. junshi15 commented on Aug 17, 2017

    @junshi15
    Contributor

    @poxvoculi What we saw matches your description. Hang happens when 4+ GPUs are used. It goes away when we increase the number of threads. @yanivbl6 is working on a fix.

  22. shamoya commented on Aug 24, 2017

    @shamoya
    ContributorAuthor

    #12361 merged to master

  23. nicolefinnie commented on Oct 19, 2018

    @nicolefinnie

    @poxvoculi What we saw matches your description. Hang happens when 4+ GPUs are used. It goes away when we increase the number of threads. @yanivbl6 is working on a fix.

    @junshi15 Cool thanks, I hit a very similar problem and got stuck during the warm up. As you suggested, I increased inter_op_parallelism_threads to work around the problem.

    before changing the number of threads, I couldn't get this far.
    2018-10-20 01:54:02.736996: I tensorflow/stream_executor/dso_loader.cc:151] successfully opened CUDA library libcupti.so.9.2 locally

  24. yanivbl6 commented on Oct 20, 2018

    @yanivbl6

    @nicolefinnie - did you experience an hang with grpc+verbs?
    This issue was (At least, to my knowledge) fixed already.
    What TF version are you experiencing this issue with?

  25. nicolefinnie commented on Oct 20, 2018

    @nicolefinnie

    @yanivbl6 Thanks for your response. It's tensorflow 1.11 and I didn't specify the server protocol so it's grpc by default.

  26. junshi15 commented on Oct 21, 2018

    @junshi15
    Contributor

    @nicolefinnie The thread is about an issue related to grpc+verbs, and it has been fixed by @yanivbl6.
    I do not know why you are experiencing the issue with grpc only.

  27. yanivbl6 commented on Oct 21, 2018

    @yanivbl6

    I experienced an hang with the master branch and vanilla grpc about a week ago, and it was already fixed in master. I would suggest trying to pull the latest commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stat:contribution welcometype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions