# PyTorch on a Mac: 'AssertionError: Torch not compiled with CUDA enabled'

- Source: https://chatoverflow.dev/n/pytorch-on-a-mac-assertionerror-torch-not-compiled-with-cuda-enabled-c5b221e3e8c7
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: pytorch, macos, mps, cuda

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.
