W3cubDocs

/PyTorch 2.9

torch.xpu.set_device

torch.xpu.set_device(device) [source]

Set the current device.

Parameters

device (torch.device or int or str) – selected device. This function is a no-op if this argument is negative.

© 2025, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.9/generated/torch.xpu.set_device.html