Skip to content

Commit

Permalink
polish api code & example (#27696)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwhql committed Oct 9, 2020
1 parent c826bcb commit bcc3472
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions python/paddle/fluid/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,31 +380,35 @@ def cuda_places(device_ids=None):
For multi-card tasks, please use `FLAGS_selected_gpus` environment variable to set the visible GPU device.
The next version will fix the problem with `CUDA_VISIBLE_DEVICES` environment variable.
This function creates a list of :code:`fluid.CUDAPlace` objects.
This function creates a list of :code:`paddle.CUDAPlace` objects.
If :code:`device_ids` is None, environment variable of
:code:`FLAGS_selected_gpus` would be checked first. For example, if
:code:`FLAGS_selected_gpus=0,1,2`, the returned list would
be [fluid.CUDAPlace(0), fluid.CUDAPlace(1), fluid.CUDAPlace(2)].
be [paddle.CUDAPlace(0), paddle.CUDAPlace(1), paddle.CUDAPlace(2)].
If :code:`FLAGS_selected_gpus` is not set, all visible
gpu places would be returned according to the :code:`CUDA_VISIBLE_DEVICES` environment variable.
If :code:`device_ids` is not None, it should be the device
ids of GPUs. For example, if :code:`device_ids=[0,1,2]`,
the returned list would be
[fluid.CUDAPlace(0), fluid.CUDAPlace(1), fluid.CUDAPlace(2)].
[paddle.CUDAPlace(0), paddle.CUDAPlace(1), paddle.CUDAPlace(2)].
Parameters:
device_ids (list or tuple of int, optional): list of GPU device ids.
Returns:
list of fluid.CUDAPlace: Created GPU place list.
list of paddle.CUDAPlace: Created GPU place list.
Examples:
.. code-block:: python
import paddle.fluid as fluid
cuda_places = fluid.cuda_places()
import paddle
import paddle.static as static
paddle.enable_static()
cuda_places = static.cuda_places()
"""
assert core.is_compiled_with_cuda(), \
Expand All @@ -418,7 +422,7 @@ def cuda_places(device_ids=None):

def cpu_places(device_count=None):
"""
This function creates a list of :code:`fluid.CPUPlace` objects, and returns the created list.
This function creates a list of :code:`paddle.CPUPlace` objects, and returns the created list.
If :code:`device_count` is None, the device count would
be determined by environment variable :code:`CPU_NUM`.
Expand All @@ -431,13 +435,17 @@ def cpu_places(device_count=None):
device_count (int, optional): device number. Default: None.
Returns:
list of fluid.CPUPlace: Created list of CPU places.
list of paddle.CPUPlace: Created list of CPU places.
Examples:
.. code-block:: python
import paddle.fluid as fluid
cpu_places = fluid.cpu_places()
import paddle
import paddle.static as static
paddle.enable_static()
cpu_places = static.cpu_places()
"""

if device_count is None:
Expand Down

0 comments on commit bcc3472

Please sign in to comment.