@@ -5,7 +5,7 @@ date: Last Updated: October 2025
55## System-Specific Guidance
66
77- [ Windows] ( #windows )
8- - [ Apple Silicon] ( #apple-silicon )
8+ - [ MacOS ( Apple Silicon) ] ( #macos- apple-silicon )
99- [ Conda] ( #conda )
1010- [ GitHub Codespace] ( #github-codespace )
1111
@@ -136,14 +136,64 @@ cmake --install .
136136```
137137
138138
139- ### Apple Silicon
139+ ### MacOS ( Apple Silicon)
140140
141- FTorch can successfully be built on Apple Silicon machines, including utilising the MPS backend,
142- following the [ regular CMake instructions] ( |page|/installation/general.html ) .
141+ FTorch can be built on MacOS Apple Silicon machines, including utilising
142+ the MPS backend, by following the
143+ [ regular CMake instructions] ( |page|/installation/general.html ) with a few additions as
144+ detailed below.
143145
144146To leverage MPS include the ` -DGPU_DEVICE=MPS `
145147[ CMake flag] ( |page|/installation/general.html#cmake-build-options ) at build time.
146148
149+ #### Dependencies
150+
151+ The system clang compilers (` clang ` and ` clang++ ` ) should be used for C and C++.
152+ This avoids ABI incompatibilities with LibTorch and ensures proper linkage with
153+ macOS system libraries.
154+
155+ Apple does not provide a Fortran compiler so users will need to install one.
156+ We recommend GNU's ` gfortran ` which comes with GCC.
157+
158+ Users will additionally need to install OpenMP (and, for some examples, Open-MPI).
159+ This can be done e.g. using the [ homebrew package manager] ( https://brew.sh/ ) with:
160+ ```
161+ brew install gcc openmpi libomp
162+ ```
163+
164+ #### Building
165+
166+ MacOS requires explicit linking to the C++ standard library and OpenMP support via
167+ ` libomp ` . This can be done through C and C++ flags at compilation time:
168+ - ` -Xpreprocessor -fopenmp ` which tells clang to use OpenMP, with ` -Xpreprocessor `
169+ passing the flag to the preprocessor,
170+ - ` -I<path/to/libomp>/include ` to find OpenMP headers,
171+ - ` -stdlib=libc++ ` to ensure use of the native MacOS C++ standard library, and
172+ - ` -L<path/to/libomp>/lib -lomp ` to link against the OpenMP library.
173+
174+ If using homebrew you can replace ` <path/to/libomp> ` with ` $(brew --prefix libomp) ` .
175+
176+ Example CMake command:
177+ ``` sh
178+ cmake .. \
179+ -DCMAKE_C_COMPILER=clang \
180+ -DCMAKE_CXX_COMPILER=clang++ \
181+ -DCMAKE_Fortran_COMPILER=gfortran \
182+ -DCMAKE_C_FLAGS=" -Xpreprocessor -fopenmp -I<path/to/libomp>/include" \
183+ -DCMAKE_CXX_FLAGS=" -stdlib=libc++ -Xpreprocessor -fopenmp -I<path/to/libomp>/include" \
184+ -DCMAKE_EXE_LINKER_FLAGS=" -L<path/to/libomp>/lib -lomp" \
185+ -DGPU_DEVICE=MPS
186+ cmake --build .
187+ cmake --install .
188+ ```
189+
190+ To build without support for Apple Silicon MPS acceleration, remove the ` -DGPU_DEVICE=MPS ` .
191+
192+ We recommend Mac users review the MacOS continuous integration workflow
193+ ([ ` .github/workflows/test_suite_macos_cpu_clang.yml ` ] ( https://github.com/Cambridge-ICCS/FTorch/blob/main/.github/workflows/test_suite_macos_cpu_clang.yml ) )
194+ for more information, as this provides another example of how to build and run
195+ FTorch and its integration tests.
196+
147197
148198### Conda
149199
0 commit comments