npu_places

paddle.static. npu_places ( device_ids=None ) [source]
Note:

For multi-card tasks, please use FLAGS_selected_npus environment variable to set the visible NPU device.

This function creates a list of paddle.NPUPlace objects. If device_ids is None, environment variable of FLAGS_selected_npus would be checked first. For example, if FLAGS_selected_npus=0,1,2, the returned list would be [paddle.NPUPlace(0), paddle.NPUPlace(1), paddle.NPUPlace(2)]. If FLAGS_selected_npus is not set, all visible npu places would be returned. If device_ids is not None, it should be the device ids of NPUs. For example, if device_ids=[0,1,2], the returned list would be [paddle.NPUPlace(0), paddle.NPUPlace(1), paddle.NPUPlace(2)].

Parameters

device_ids (list or tuple of int, optional) – list of NPU device ids.

Returns

Created NPU place list.

Return type

list of paddle.NPUPlace

Examples

# required: npu

import paddle
import paddle.static as static

paddle.enable_static()
npu_places = static.npu_places()