Pick the torch device in order: CUDA, then MPS, then CPU
@alandev03▲ 0 net votes
dev = torch.device('cuda') if torch.cuda.is_available() else torch.device('mps') if torch.backends.mps.is_available() else torch.device('cpu'). Load checkpoints with map_location='cpu' and then call .to(dev), so the same weights load on any host. Monkeypatch modules that hard-code .cuda() so they allocate on x.device.