Skip to content

Commit

Permalink
[GpuPs]pybind core (PaddlePaddle#37287)
Browse files Browse the repository at this point in the history
* pybind core

* set use psgpu
  • Loading branch information
Thunderbrook authored and Zjq9409 committed Dec 10, 2021
1 parent 0d4c126 commit 07c8adc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions python/paddle/fluid/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,19 @@ def _prepare_to_run(self):
self.dataset.set_data_feed_desc(self.desc())
self.dataset.create_readers()

def _set_use_ps_gpu(self, use_ps_gpu):
def _set_use_ps_gpu(self, psgpu):
"""
set use_ps_gpu flag
Args:
use_ps_gpu: bool
"""
self.use_ps_gpu = use_ps_gpu
self.use_ps_gpu = True
# if not defined heterps with paddle, users will not use psgpu
if not core._is_compiled_with_heterps():
self.use_ps_gpu = 0
self.use_ps_gpu = False
elif self.use_ps_gpu:
self.psgpu = core.PSGPU()
self.psgpu = psgpu

def _finish_to_run(self):
self.dataset.destroy_readers()
Expand Down
12 changes: 6 additions & 6 deletions python/paddle/fluid/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1813,9 +1813,9 @@ def _run_from_dataset(self,
if program._pipeline_opt is None:
if program._heter_pipeline_opt is None:
self._dump_debug_info(program=program, trainer=trainer)
# in case of calling _set_use_ps_gpu explicitly
if dataset.use_ps_gpu is False:
dataset._set_use_ps_gpu(trainer.proto_desc.use_ps_gpu)
# warning if dataset not set psgpu in psgpu mode
if dataset.use_ps_gpu is False and trainer.proto_desc.use_ps_gpu:
logging.warning("dataset should call set_use_ps_gpu in PsGpu mode")
dataset._dynamic_adjust_before_train(trainer.proto_desc.thread_num)

if program._heter_pipeline_opt is None:
Expand Down Expand Up @@ -1948,9 +1948,9 @@ def _get_real_program_fetch_list():
# NOTE: only for debug, very slow
# self._dump_debug_info(program=program, trainer=trainer)

# in case of calling _set_use_ps_gpu explicitly
if dataset.use_ps_gpu is False:
dataset._set_use_ps_gpu(trainer.proto_desc.use_ps_gpu)
# warning if dataset not set psgpu in psgpu mode
if dataset.use_ps_gpu is False and trainer.proto_desc.use_ps_gpu:
logging.warning("dataset should call set_use_ps_gpu in PsGpu mode")
dataset._dynamic_adjust_before_train(trainer.proto_desc.thread_num)

trainer_desc = trainer._desc() # slow, cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def test_communicator_ps_gpu(self):
dataset.init(
batch_size=32, thread_num=1, pipe_command="cat", use_var=slots_vars)
dataset.set_filelist(["test_communicator_ps_gpu.txt"])
dataset._set_use_ps_gpu(1)
dataset.set_date("20211111")
dataset.load_into_memory(is_shuffle=True)

Expand Down

0 comments on commit 07c8adc

Please sign in to comment.