Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Are there any specific dependencies required for building PyTorch on macOS


Are there any specific dependencies required for building PyTorch on macOS


Building PyTorch on macOS requires several dependencies and considerations:

1. macOS Version: PyTorch is supported on macOS 10.15 (Catalina) or later[3]. For GPU support on newer Macs with M1/M2/M3 chips, macOS 12.3 or later is necessary[1].

2. Python Version: It is recommended to use Python 3.9 to 3.12 for compatibility with PyTorch[3].

3. Package Manager: You can use either pip or Anaconda to install PyTorch. Anaconda is recommended as it provides a sandboxed environment with all necessary dependencies[3].

4. GPU Support: Traditional CUDA support is not available on macOS because CUDA only works with NVIDIA GPUs, which are not typically found in Macs[8]. However, Macs with M1/M2/M3 chips can use the MPS (Metal Performance Shaders) backend for GPU acceleration. This requires PyTorch to be installed with MPS support, which is available in nightly builds[1].

5. Additional Dependencies: For certain configurations, additional tools like XCode, Openblas, and OpenMP might be needed, especially if you're compiling PyTorch from source[5]. However, these are not typically required for standard installations using pip or Anaconda.

6. Installation Index: PyTorch wheels are hosted on specific indexes (e.g., CPU-only builds are on `https://download.pytorch.org/whl/cpu`), and you may need to specify these indexes during installation depending on your hardware[2][6].

Citations:
[1] https://wiki.cci.arts.ac.uk/books/it-computing/page/enable-gpu-support-with-pytorch-macos
[2] https://docs.astral.sh/uv/guides/integration/pytorch/
[3] https://pytorch.org/get-started/locally/
[4] https://botpenguin.com/blogs/how-to-install-pytorch-a-step-by-step-guide
[5] https://github.com/TomHeaven/pytorch-osx-build/blob/master/BuildInstractions-1.0.1.md
[6] https://prefix-dev.github.io/pixi/dev/features/pytorch/
[7] https://stackoverflow.com/questions/73986257/pytorch-1-12-on-mac-monterey
[8] https://stackoverflow.com/questions/63423463/using-pytorch-cuda-on-macbook-pro