[错误] 课程代码仅限 CUDA,不支持 Apple Silicon (MPS) 设备路径

作者: Jayantkhandebharad创建于 2026年6月15日更新于 2026年7月5日
  1. On an Apple Silicon Mac (macOS 12.3+) with PyTorch installed — confirm the GPU is real: python3 -c "import torch; print(torch.backends.mps.is_available())"True.
  2. Run a GPU lesson, e.g. Python phases/04-computer-vision/04-image-classification/code/main.py.
  3. Observe device resolves to cpu (line 195: device = "cuda" if torch.cuda.is_available() else "cpu") — the available GPU is never used.
  4. Or run Python phases/00-setup-and-tooling/03-gpu-setup-and-cloud/code/gpu_check.py → prints "CUDA available: False" and exits, reporting no GPU despite MPS being available.
    File Line Problem
    phases/00-setup-and-tooling/01-dev-environment/docs/en.md Step 6 GPU snippet only shows nvidia-smi + CUDA install + torch.cuda.is_available(); no MPS equivalent.
    phases/00-setup-and-tooling/03-gpu-setup-and-cloud/code/gpu_check.py 14–41 Hard-codes .to("cuda") and torch.cuda.synchronize(); reports no GPU on Apple Silicon.
    phases/00-setup-and-tooling/01-dev-environment/code/verify.py 19–20 Only probes torch.cuda.is_available() / get_device_name(0).
    phases/03-deep-learning-core/11-intro-to-pytorch/code/pytorch_intro.py CUDA/CPU only device selection.
    phases/04-computer-vision/04-image-classification/code/main.py 195 device = "cuda" if torch.cuda.is_available() else "cpu".

内容来源: rohitg00/ai-engineering-from-scratch