Skip to content

Commit

Permalink
Reproduce profiler failure on multi-gpu.
Browse files Browse the repository at this point in the history
  • Loading branch information
panyx0718 committed Mar 14, 2018
1 parent 8601864 commit ebde3b1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions python/paddle/fluid/tests/unittests/test_parallel_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest

import paddle.fluid as fluid
import paddle.fluid.profiler as profiler
import numpy


Expand Down Expand Up @@ -60,20 +61,23 @@ def run_test(self, callback, feed, fetch):
feed=feed,
fetch=fetch,
place=gpu,
use_parallel=False)
use_parallel=False,
use_gpu=True)
result_gpu_parallel = self._run_test_impl_(
callback=callback,
feed=feed,
fetch=fetch,
place=gpu,
use_parallel=True)
use_parallel=True,
use_gpu=True)
result_gpu_nccl = self._run_test_impl_(
callback=callback,
feed=feed,
fetch=fetch,
place=gpu,
use_parallel=True,
use_nccl=True)
use_nccl=True,
use_gpu=True)
self._assert_same_(fetch, result_cpu, result_cpu_parallel,
result_gpu, result_gpu_parallel, result_gpu_nccl)
else:
Expand All @@ -85,7 +89,8 @@ def _run_test_impl_(self,
fetch,
place,
use_parallel=False,
use_nccl=False):
use_nccl=False,
use_gpu=False):
"""
Run a single test, returns the fetch values
Args:
Expand Down Expand Up @@ -132,7 +137,12 @@ def _run_test_impl_(self,

exe = fluid.Executor(place)
exe.run(startup)
return exe.run(main, feed=feed, fetch_list=fetch)
if use_gpu:
profile_type = 'GPU'
else:
profile_type = 'CPU'
with profiler.profiler(profile_type, 'total', '/tmp/profiler'):
return exe.run(main, feed=feed, fetch_list=fetch)

def _assert_same_(self, fetch, *args):
"""
Expand Down

0 comments on commit ebde3b1

Please sign in to comment.