Learn Before
Concept

Querying Tensor Device Location

Deep learning frameworks provide programmatic mechanisms to determine the specific hardware device—such as main memory (CPU) or a specific GPU—where a tensor is currently stored. Depending on the framework, this information can be retrieved using attributes or methods on the tensor object, such as .device in PyTorch and TensorFlow, .device() in JAX, or .ctx in MXNet.

0

1

Updated 2026-05-09

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L