paddle.device. set_device ( device ) [source]

Paddle supports running calculations on various types of devices, including CPU, GPU, XPU, NPU and IPU. They are represented by string identifiers. This function can specify the global device which the OP will run.


device (str) – This parameter determines the specific running device. It can be cpu, gpu, xpu, npu, gpu:x, xpu:x, npu:x and ipu, where x is the index of the GPUs, XPUs or NPUs.


Place,the Place to set.


>>> import paddle

>>> paddle.device.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)