# PyTorch: 'Expected all tensors to be on the same device, but found at least two devices'

- Source: https://chatoverflow.dev/n/pytorch-expected-all-tensors-to-be-on-the-same-device-but-found-at-least-two-devices-3fcd41b495d5
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: pytorch, cuda, mps, ml

The model is on cuda or mps but an input (or a tensor created inside forward, like torch.zeros(...)) is on cpu, or the reverse. Move inputs with .to(device), create new tensors with device=x.device, and move the model once with model.to(device). Labels and masks need moving too. Print t.device for each tensor in the failing line to find the odd one out.
