未验证 提交 bcc34724 编写于 作者: C Chen Weihang 提交者: GitHub

polish api code & example (#27696)

上级 c826bcb2
...@@ -380,31 +380,35 @@ def cuda_places(device_ids=None): ...@@ -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. 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. 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 If :code:`device_ids` is None, environment variable of
:code:`FLAGS_selected_gpus` would be checked first. For example, if :code:`FLAGS_selected_gpus` would be checked first. For example, if
:code:`FLAGS_selected_gpus=0,1,2`, the returned list would :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 If :code:`FLAGS_selected_gpus` is not set, all visible
gpu places would be returned according to the :code:`CUDA_VISIBLE_DEVICES` environment variable. 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 If :code:`device_ids` is not None, it should be the device
ids of GPUs. For example, if :code:`device_ids=[0,1,2]`, ids of GPUs. For example, if :code:`device_ids=[0,1,2]`,
the returned list would be the returned list would be
[fluid.CUDAPlace(0), fluid.CUDAPlace(1), fluid.CUDAPlace(2)]. [paddle.CUDAPlace(0), paddle.CUDAPlace(1), paddle.CUDAPlace(2)].
Parameters: Parameters:
device_ids (list or tuple of int, optional): list of GPU device ids. device_ids (list or tuple of int, optional): list of GPU device ids.
Returns: Returns:
list of fluid.CUDAPlace: Created GPU place list. list of paddle.CUDAPlace: Created GPU place list.
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle
cuda_places = fluid.cuda_places() import paddle.static as static
paddle.enable_static()
cuda_places = static.cuda_places()
""" """
assert core.is_compiled_with_cuda(), \ assert core.is_compiled_with_cuda(), \
...@@ -418,7 +422,7 @@ def cuda_places(device_ids=None): ...@@ -418,7 +422,7 @@ def cuda_places(device_ids=None):
def cpu_places(device_count=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 If :code:`device_count` is None, the device count would
be determined by environment variable :code:`CPU_NUM`. be determined by environment variable :code:`CPU_NUM`.
...@@ -431,13 +435,17 @@ def cpu_places(device_count=None): ...@@ -431,13 +435,17 @@ def cpu_places(device_count=None):
device_count (int, optional): device number. Default: None. device_count (int, optional): device number. Default: None.
Returns: Returns:
list of fluid.CPUPlace: Created list of CPU places. list of paddle.CPUPlace: Created list of CPU places.
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle
cpu_places = fluid.cpu_places() import paddle.static as static
paddle.enable_static()
cpu_places = static.cpu_places()
""" """
if device_count is None: if device_count is None:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册