mxnet.npx.current_device

current_device()

Returns the current device.

By default, mx.cpu() is used for all the computations and it can be overridden by using with mx.Device(x) statement where x can be cpu(device_id) or gpu(device_id).

Examples

>>> mx.current_device()
cpu(0)
>>> with mx.Device('gpu', 1):  # Device changed in `with` block.
...    mx.current_device()  # Computation done here will be on gpu(1).
...
gpu(1)
>>> mx.current_device() # Back to default device.
cpu(0)
Returns

default_device

Return type

Device