From b2df6de8605d6b8f557ad57baa89c884a06348cd Mon Sep 17 00:00:00 2001 From: jerrywgz Date: Mon, 22 Apr 2019 06:26:03 +0000 Subject: [PATCH] fix potential hung in generate proposals, test=develop --- .../operators/detection/generate_proposals_op.cu | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/operators/detection/generate_proposals_op.cu b/paddle/fluid/operators/detection/generate_proposals_op.cu index a0b993771..2dfd9befd 100644 --- a/paddle/fluid/operators/detection/generate_proposals_op.cu +++ b/paddle/fluid/operators/detection/generate_proposals_op.cu @@ -286,7 +286,8 @@ static void NMS(const platform::CUDADeviceContext &ctx, const Tensor &proposals, } int *keep = keep_out->mutable_data({num_to_keep}, ctx.GetPlace()); memory::Copy(place, keep, platform::CPUPlace(), keep_vec.data(), - sizeof(int) * num_to_keep, 0); + sizeof(int) * num_to_keep, ctx.stream()); + ctx.Wait(); } template @@ -329,7 +330,8 @@ static std::pair ProposalForOneImage( int keep_num; const auto gpu_place = boost::get(ctx.GetPlace()); memory::Copy(platform::CPUPlace(), &keep_num, gpu_place, - keep_num_t.data(), sizeof(int), 0); + keep_num_t.data(), sizeof(int), ctx.stream()); + ctx.Wait(); keep_index.Resize({keep_num}); Tensor scores_filter, proposals_filter; @@ -438,9 +440,12 @@ class CUDAGenerateProposalsKernel : public framework::OpKernel { Tensor &scores = box_score_pair.second; memory::Copy(place, rpn_rois_data + num_proposals * 4, place, - proposals.data(), sizeof(T) * proposals.numel(), 0); + proposals.data(), sizeof(T) * proposals.numel(), + dev_ctx.stream()); memory::Copy(place, rpn_roi_probs_data + num_proposals, place, - scores.data(), sizeof(T) * scores.numel(), 0); + scores.data(), sizeof(T) * scores.numel(), + dev_ctx.stream()); + dev_ctx.Wait(); num_proposals += proposals.dims()[0]; offset.emplace_back(num_proposals); } -- GitLab