chainer.backends.cuda.to_gpu

chainer.backends.cuda.to_gpu(array, device=None, stream=None)[source]

Copies the given CPU array to the specified device.

Parameters
  • array (array, None, list or tuple) – Array or arrays to be sent to GPU.

  • device – CUDA device specifier. If None or cuda.DummyDevice, the arrays will be copied to the current CUDA device.

  • stream (Stream) – (deprecated since v3.0.0) CUDA stream. If not None, the copy runs asynchronously.

Returns

Array or arrays on GPU.

If some of the arrays are already on GPU, then this function just returns those arrays without performing any copy.

If input arrays include None, it is returned as None as is.

Return type

cupy.ndarray, list or tuple