Skip to content

Commit 8b7516e

Browse files
committed
test memopt fit a line demo with nccl
1 parent abb9405 commit 8b7516e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

python/paddle/fluid/tests/book_memory_optimization/test_memopt_fit_a_line.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@
2626
x = fluid.layers.data(name='x', shape=[13], dtype='float32')
2727
y = fluid.layers.data(name='y', shape=[1], dtype='float32')
2828

29-
places = fluid.layers.get_places(device_count=2, device_type='CPU')
30-
pd = fluid.layers.ParallelDo(places)
29+
device_type = 'CPU'
30+
use_nccl = False
31+
place = fluid.CPUPlace()
32+
if fluid.core.is_compiled_with_cuda():
33+
device_type = 'CUDA'
34+
use_nccl = True
35+
place = fluid.CUDAPlace(0)
36+
37+
places = fluid.layers.get_places(device_count=2, device_type=device_type)
38+
pd = fluid.layers.ParallelDo(places, use_nccl=use_nccl)
3139
with pd.do():
3240
x_ = pd.read_input(x)
3341
y_ = pd.read_input(y)
@@ -54,7 +62,6 @@
5462
# paddle.dataset.uci_housing.train(), buf_size=500),
5563
# batch_size=BATCH_SIZE)
5664

57-
place = fluid.CPUPlace()
5865
feeder = fluid.DataFeeder(place=place, feed_list=[x, y])
5966
exe = fluid.Executor(place)
6067

0 commit comments

Comments
 (0)