File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
python/paddle/fluid/tests/book_memory_optimization Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 26
26
x = fluid .layers .data (name = 'x' , shape = [13 ], dtype = 'float32' )
27
27
y = fluid .layers .data (name = 'y' , shape = [1 ], dtype = 'float32' )
28
28
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 )
31
39
with pd .do ():
32
40
x_ = pd .read_input (x )
33
41
y_ = pd .read_input (y )
54
62
# paddle.dataset.uci_housing.train(), buf_size=500),
55
63
# batch_size=BATCH_SIZE)
56
64
57
- place = fluid .CPUPlace ()
58
65
feeder = fluid .DataFeeder (place = place , feed_list = [x , y ])
59
66
exe = fluid .Executor (place )
60
67
You can’t perform that action at this time.
0 commit comments