get_device
- paddle.Tensor. get_device ( self: Tensor ) int
-
Return the device id where the Tensor is located.
- Returns
-
- The device id of the Tensor. Returns -1 for CPU tensors; for GPU tensors,
-
returns the CUDA device id (e.g., 0 for gpu:0).
- Return type
-
int
Examples
>>> import paddle >>> x = paddle.to_tensor([1, 2, 3], place=paddle.CPUPlace()) >>> x.get_device() -1 >>> >>> y = paddle.to_tensor([1, 2, 3], place=paddle.CUDAPlace(0)) >>> y.get_device() 0
