chainer.backends.cuda.get_device

chainer.backends.cuda.get_device(*args)[source]

Gets the device from a device object, an ID integer or an array object.

Note

This API is deprecated since v3.0.0. Please use get_device_from_id() or get_device_from_array() instead.

This is a convenient utility to select a correct device if the type of arg is unknown (i.e., one can use this function on arrays that may be on CPU or GPU). The returned device object supports the context management protocol of Python for the with statement.

Parameters

args – Values to specify a GPU device. The first device object, integer or cupy.ndarray object is used to select a device. If it is a device object, it is returned. If it is an integer, the corresponding device is returned. If it is a CuPy array, the device on which this array reside is returned. If any arguments are neither integers nor CuPy arrays, a dummy device object representing CPU is returned.

Returns

Device object specified by given args.

See also

See cupy.cuda.Device for the device selection not by arrays.