paddle.device. set_device ( device ) [source]

Paddle supports running calculations on various types of devices, including CPU, GPU, XPU, NPU, MLU 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, mlu, gpu:x, xpu:x, npu:x, mlu:x and ipu, where x is the index of the GPUs, XPUs, NPUs or MLUs.


import paddle

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)

Used in the guide/tutorials