set_device¶
-
paddle.
set_device
( device ) [source] -
Paddle supports running calculations on various types of devices, including CPU, GPU and XPU. They are represented by string identifiers. This function can specify the global device which the OP will run.
- Parameters
-
device (str) – This parameter determines the specific running device. It can be
cpu
,gpu:x
andxpu:x
, wherex
is the index of the GPUs or XPUs.
Examples
import paddle paddle.set_device("cpu") x1 = paddle.ones(name='x1', shape=[1, 2], dtype='int32') x2 = paddle.zeros(name='x2', shape=[1, 2], dtype='int32') data = paddle.stack([x1,x2], axis=1)