Skip to content

Commit 1a67550

Browse files
committed
polish api code & example
1 parent 162b4d6 commit 1a67550

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

python/paddle/fluid/framework.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,31 +377,35 @@ def cuda_places(device_ids=None):
377377
For multi-card tasks, please use `FLAGS_selected_gpus` environment variable to set the visible GPU device.
378378
The next version will fix the problem with `CUDA_VISIBLE_DEVICES` environment variable.
379379
380-
This function creates a list of :code:`fluid.CUDAPlace` objects.
380+
This function creates a list of :code:`paddle.CUDAPlace` objects.
381381
382382
If :code:`device_ids` is None, environment variable of
383383
:code:`FLAGS_selected_gpus` would be checked first. For example, if
384384
:code:`FLAGS_selected_gpus=0,1,2`, the returned list would
385-
be [fluid.CUDAPlace(0), fluid.CUDAPlace(1), fluid.CUDAPlace(2)].
385+
be [paddle.CUDAPlace(0), paddle.CUDAPlace(1), paddle.CUDAPlace(2)].
386386
If :code:`FLAGS_selected_gpus` is not set, all visible
387387
gpu places would be returned according to the :code:`CUDA_VISIBLE_DEVICES` environment variable.
388388
389389
If :code:`device_ids` is not None, it should be the device
390390
ids of GPUs. For example, if :code:`device_ids=[0,1,2]`,
391391
the returned list would be
392-
[fluid.CUDAPlace(0), fluid.CUDAPlace(1), fluid.CUDAPlace(2)].
392+
[paddle.CUDAPlace(0), paddle.CUDAPlace(1), paddle.CUDAPlace(2)].
393393
394394
Parameters:
395395
device_ids (list or tuple of int, optional): list of GPU device ids.
396396
397397
Returns:
398-
list of fluid.CUDAPlace: Created GPU place list.
398+
list of paddle.CUDAPlace: Created GPU place list.
399399
400400
Examples:
401401
.. code-block:: python
402402
403-
import paddle.fluid as fluid
404-
cuda_places = fluid.cuda_places()
403+
import paddle
404+
import paddle.static as static
405+
406+
paddle.enable_static()
407+
408+
cuda_places = static.cuda_places()
405409
406410
"""
407411
assert core.is_compiled_with_cuda(), \
@@ -415,7 +419,7 @@ def cuda_places(device_ids=None):
415419

416420
def cpu_places(device_count=None):
417421
"""
418-
This function creates a list of :code:`fluid.CPUPlace` objects, and returns the created list.
422+
This function creates a list of :code:`paddle.CPUPlace` objects, and returns the created list.
419423
420424
If :code:`device_count` is None, the device count would
421425
be determined by environment variable :code:`CPU_NUM`.
@@ -428,13 +432,17 @@ def cpu_places(device_count=None):
428432
device_count (int, optional): device number. Default: None.
429433
430434
Returns:
431-
list of fluid.CPUPlace: Created list of CPU places.
435+
list of paddle.CPUPlace: Created list of CPU places.
432436
433437
Examples:
434438
.. code-block:: python
435439
436-
import paddle.fluid as fluid
437-
cpu_places = fluid.cpu_places()
440+
import paddle
441+
import paddle.static as static
442+
443+
paddle.enable_static()
444+
445+
cpu_places = static.cpu_places()
438446
"""
439447

440448
if device_count is None:

0 commit comments

Comments
 (0)