xarray.DataArray.cupy.as_cupy

DataArray.cupy.as_cupy()

Converts the DataArray’s underlying array type to cupy.

For DataArrays which are initially backed by numpy the data will be immediately cast to cupy and moved to the GPU. In the case that the data was originally a Dask array each chunk will be moved to the GPU when the task graph is computed.

Returns:

cupy_da (DataArray) – DataArray with underlying data cast to cupy.

Examples

>>> import xarray as xr
>>> da = xr.tutorial.load_dataset("air_temperature").air
>>> gda = da.cupy.as_cupy()
>>> type(gda.data)
<class 'cupy.ndarray'>