From 04f73d8901b78cfb9e29d80782bd86f74fec130d Mon Sep 17 00:00:00 2001 From: Guoxia Wang Date: Mon, 10 Jan 2022 09:46:57 +0800 Subject: [PATCH] fix cuda seed bug of class_center_sample traning on multi gpu (#38815) --- paddle/fluid/operators/class_center_sample_op.cu | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/class_center_sample_op.cu b/paddle/fluid/operators/class_center_sample_op.cu index f1ccbc913d9..fad74b81e14 100644 --- a/paddle/fluid/operators/class_center_sample_op.cu +++ b/paddle/fluid/operators/class_center_sample_op.cu @@ -397,7 +397,9 @@ class ClassCenterSampleCUDAKernel : public framework::OpKernel { (NumBlocks(num_classes) * kNumCUDAThreads * vec_size) + 1) * vec_size; - auto gen_cuda = framework::GetDefaultCUDAGenerator(rank); + int device_id = + BOOST_GET_CONST(platform::CUDAPlace, ctx.GetPlace()).GetDeviceId(); + auto gen_cuda = framework::GetDefaultCUDAGenerator(device_id); if (gen_cuda->GetIsInitPy() && (!fix_seed)) { auto seed_offset = gen_cuda->IncrementOffset(offset); seed_data = seed_offset.first; -- GitLab