提交 d2cb3790 编写于 作者: Y Yu Yang

Wait all evernts

上级 4137bb4e
...@@ -420,11 +420,11 @@ struct NCCLAllReduceOpHandle : public OpHandle { ...@@ -420,11 +420,11 @@ struct NCCLAllReduceOpHandle : public OpHandle {
} }
} else { } else {
if (events_.size() > 1) { if (events_.size() > 1) {
int dev_id =
boost::get<platform::CUDAPlace>(waited_dev->GetPlace()).device;
auto stream = auto stream =
static_cast<platform::CUDADeviceContext *>(waited_dev)->stream(); static_cast<platform::CUDADeviceContext *>(waited_dev)->stream();
PADDLE_ENFORCE(cudaStreamWaitEvent(stream, events_[dev_id], 0)); for (auto &ev : events_) {
PADDLE_ENFORCE(cudaStreamWaitEvent(stream, ev.second, 0));
}
} }
} }
} }
......
...@@ -47,7 +47,7 @@ class ParallelExecutor(unittest.TestCase): ...@@ -47,7 +47,7 @@ class ParallelExecutor(unittest.TestCase):
dtypes=['float32', 'int64']) dtypes=['float32', 'int64'])
img, label = fluid.layers.read_file(reader) img, label = fluid.layers.read_file(reader)
hidden = img hidden = img
for _ in xrange(2): for _ in xrange(4):
hidden = fluid.layers.fc( hidden = fluid.layers.fc(
hidden, hidden,
size=200, size=200,
...@@ -60,7 +60,7 @@ class ParallelExecutor(unittest.TestCase): ...@@ -60,7 +60,7 @@ class ParallelExecutor(unittest.TestCase):
adam = fluid.optimizer.Adam() adam = fluid.optimizer.Adam()
adam.minimize(loss) adam.minimize(loss)
act_places = [] act_places = []
for each in [fluid.CUDAPlace(0), fluid.CUDAPlace(1)]: for each in [fluid.CUDAPlace(0)]:
p = fluid.core.Place() p = fluid.core.Place()
p.set_place(each) p.set_place(each)
act_places.append(p) act_places.append(p)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册