cuda_places

paddle.static. cuda_places ( device_ids=None ) [source]

Note

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 paddle.CUDAPlace objects.

If device_ids is None, environment variable of FLAGS_selected_gpus would be checked first. For example, if FLAGS_selected_gpus=0,1,2, the returned list would be [paddle.CUDAPlace(0), paddle.CUDAPlace(1), paddle.CUDAPlace(2)]. If FLAGS_selected_gpus is not set, all visible gpu places would be returned according to the CUDA_VISIBLE_DEVICES environment variable.

If device_ids is not None, it should be the device ids of GPUs. For example, if device_ids=[0,1,2], the returned list would be [paddle.CUDAPlace(0), paddle.CUDAPlace(1), paddle.CUDAPlace(2)].

Parameters

device_ids (list|tuple, optional) – A list/tuple of int of GPU device ids.

Returns

Created GPU place list.

Return type

list of paddle.CUDAPlace

Examples

>>> 
>>> import paddle
>>> import paddle.static as static

>>> paddle.device.set_device('gpu')
>>> paddle.enable_static()

>>> cuda_places = static.cuda_places()