current_device

paddle.cuda. current_device ( ) int [source]

Return the index of a currently selected device.

Returns

The index of the currently selected device.

Return type

int

Examples

>>> 
>>> import paddle
>>> device_id = paddle.device.current_device() # this is equivalent to paddle.cuda.current_device()
>>> print(f"Current device index: {device_id}")