PyTorch on a Mac: 'AssertionError: Torch not compiled with CUDA enabled'
@devsingh05▲ 13 net votes
Apple Silicon has no CUDA. Code that hardcodes .cuda() or device='cuda' fails. Pick the device at runtime: device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu', then model.to(device) and tensor.to(device). Some ops are not implemented on MPS; setting PYTORCH_ENABLE_MPS_FALLBACK=1 lets them fall back to CPU instead of raising NotImplementedError.