|
[Sponsors] |
[OpenFOAM.com] Installing OpenFOAM on MacOS with Apple Silicon |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 16, 2023, 12:18 |
Installing OpenFOAM on MacOS with Apple Silicon
|
#1 | |||||
New Member
Kevin Nolan
Join Date: Nov 2012
Posts: 13
Rep Power: 14 |
I recently got a new Mac and wanted to build OpenFOAM natively without the need for virtualisation to make the most of the core count of the M3 Max.
Here is what I needed to do to get it running based on the patches and guide by Alexey Matveichev, so many thanks to his efforts! https://github.com/mrklein/openfoam-os-x I installed v2206. My 16" MacBook Pro is running Sonoma 14.2 (23C64). I have a 16 core M3 Max. The main issues I had were related to clearing of environmental variables by SIP when running scripts and linking scotch. This post will follow and tweak this guide: https://github.com/mrklein/openfoam-...ase-&-Homebrew First install Xcode and the Xcode command line tools. You can do this from the app store. Check the command line tools are installed: Code:
$ xcode-select --install https://brew.sh The guide then asks you to install some dependencies, however the version of scotch failed to install. Instead install the unmodified version of scotch which in my case is 7.0.4. Code:
brew install --cask paraview $ brew install open-mpi $ brew install boost $ brew install cgal $ brew install metis $ brew install libomp $ brew install scotch $ brew install mrklein/foam/parmgridgen Code:
$ cd $HOME $ hdiutil create -size 8.3g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle $ mkdir -p OpenFOAM $ hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle Code:
$ curl -L http://dl.openfoam.com/source/v2206/OpenFOAM-v2206.tgz > OpenFOAM-v2206.tgz $ curl -L http://dl.openfoam.com/source/v2206/ThirdParty-v2206.tgz > ThirdParty-v2206.tgz Next extract the tarballs into the new OpenFOAM volume. Code:
$ cd OpenFOAM $ tar xzf $HOME/OpenFOAM-v2206.tgz $ tar xzf $HOME/ThirdParty-v2206.tgz Let's go into OpenFOAM-v2206 and download the patch file and then apply it. Code:
cd OpenFOAM-v2206 $ curl -L https://raw.githubusercontent.com/mrklein/openfoam-os-x/master/OpenFOAM-v2206.patch > OpenFOAM-v2206.patch $ git apply OpenFOAM-v2206.patch Looking at our scotch install info: Code:
brew info scotch Code:
==> scotch: stable 7.0.4 (bottled), HEAD Package for graph partitioning, graph clustering, and sparse matrix ordering https://gitlab.inria.fr/scotch/scotch /opt/homebrew/Cellar/scotch/7.0.4 (227 files, 11.3MB) * Poured from bottle using the formulae.brew.sh API on 2023-12-15 at 15:32:38 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/s/scotch.rb License: CECILL-C ==> Dependencies Build: bison ✘ Required: open-mpi ✔ ==> Options --HEAD Install HEAD version ==> Analytics install: 62 (30 days), 169 (90 days), 435 (365 days) install-on-request: 60 (30 days), 167 (90 days), 432 (365 days) build-error: 0 (30 days) Code:
export SCOTCH_VERSION=scotch-system export SCOTCH_ARCH_PATH=/opt/homebrew/Cellar/scotch/7.0.4 Comment out the existing entries and save the file. Next run these commands to update some necessary settings: Code:
$ mkdir -p $HOME/.OpenFOAM $ echo 'WM_COMPILER=Clang' > $HOME/.OpenFOAM/prefs.sh $ echo 'WM_COMPILE_OPTION=Opt' >> $HOME/.OpenFOAM/prefs.sh $ echo 'WM_MPLIB=SYSTEMOPENMPI' >> $HOME/.OpenFOAM/prefs.sh $ echo 'export WM_NCOMPPROCS=$(sysctl -n hw.ncpu)' >> $HOME/.OpenFOAM/prefs.sh $ echo 'WM_LABEL_SIZE=32' >> $HOME/.OpenFOAM/prefs.sh $ source etc/bashrc $ [ "$(ulimit -n)" -lt "4096" ] && ulimit -n 4096 Now we can build Code:
$ cd $HOME/OpenFOAM/OpenFOAM-v2206 $ ./Allwmake > log.Allwmake 2>&1 Code:
$ tail -f $HOME/OpenFOAM/OpenFOAM-v2206/log.Allwmake Code:
mkdir -p $HOME/.OpenFOAM echo 'v2206' > $HOME/.OpenFOAM/OpenFOAM-release Code:
if [ -f "$HOME/.OpenFOAM/OpenFOAM-release" ]; then FOAM_DISK_IMAGE=${FOAM_DISK_IMAGE:-"$HOME/OpenFOAM.sparsebundle"} FOAM_MOUNT_POINT=${FOAM_MOUNT_POINT:-"$HOME/OpenFOAM"} FOAM_VERSION=$(cat $HOME/.OpenFOAM/OpenFOAM-release) if [ ! -f "$HOME/OpenFOAM/OpenFOAM-$FOAM_VERSION/etc/bashrc" ]; then hdiutil attach -quiet -mountpoint "$FOAM_MOUNT_POINT" "$FOAM_DISK_IMAGE" && . "$HOME/OpenFOAM/OpenFOAM-$FOAM_VERSION/etc/bashrc" else source "$HOME/OpenFOAM/OpenFOAM-$FOAM_VERSION/etc/bashrc" fi fi Finally you can run the OpenFoam Benchmark, but you need to tweak a could have things. Download the OpenFOAM.com specific zip file from this post: \OpenFOAM benchmarks on various hardware This runs simpleFOAM on various core counts using a script. As mentioned before System Integrity Protection can clear required environmental variables when running scripts. The suggested fix for this is to include Code:
source $WM_PROJECT_DIR/etc/bashrc The run.tst script needs to be edited. I changed the core counts to: Quote:
Quote:
Quote:
to replace the reference in line 279 from Quote:
Quote:
It's not important but you can change: Code:
writeCompression uncompressed; Code:
writeCompression off; Code:
./run.tst # cores Wall time (s): ------------------------ 16 87.19 12 53.91 10 57.39 8 63.66 6 74.18 4 110.1 2 197.9 1 345.8 Last edited by Kolan; December 17, 2023 at 12:17. |
||||||
December 21, 2023, 14:14 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
More changes for handling SIP, rpath installation and xcode will be in OpenFOAM-v2312. Presumably will need less patching (hopefully no patching).
It would be useful if you would also give that a spin in the next days/weeks and see if some of your recipe can be reduced. |
|
December 21, 2023, 14:16 |
|
#3 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Is the homebrew recipe for scotch now fixed to compile without threaded MPI (which is a real performance killer for OpenFOAM)?
|
|
December 22, 2023, 09:56 |
|
#4 |
New Member
Kevin Nolan
Join Date: Nov 2012
Posts: 13
Rep Power: 14 |
Yes, it seems that scotch is now behaving as expected.
Once I get my exam grading done I'll give v2312 a look! |
|
December 23, 2023, 09:40 |
|
#5 | |
New Member
Gabriel Gerlero
Join Date: Jan 2022
Posts: 21
Rep Power: 4 |
Quote:
BTW, for those interested in running OpenFOAM natively on macOS, my project at https://github.com/gerlero/openfoam-app automates the builds (for those who want to compile from source) and also provides pre-compiled binaries (for those who just want to get up and running as fast as possible). |
||
December 23, 2023, 10:03 |
|
#6 |
New Member
Kevin Nolan
Join Date: Nov 2012
Posts: 13
Rep Power: 14 |
And it is an excellent way to get it running too.
You will know better than me but Ill report back soon on how I get on. |
|
March 15, 2024, 01:56 |
|
#7 |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Hi,
Did you test v2312? Any improvements with SIP? I have problems with Code:
The dummy Pstream library cannot be used in parallel mode Code:
source $WM_PROJECT_DIR/etc/bashrc Did you have similar issues and how did you solve it? |
|
March 15, 2024, 08:54 |
|
#8 |
New Member
Kevin Nolan
Join Date: Nov 2012
Posts: 13
Rep Power: 14 |
I've yet to have time to test v2312 but I've had no issues with SIP. After following the steps in my initial post I've had no further issues with v2306.
|
|
April 2, 2024, 06:19 |
|
#9 |
New Member
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15 |
Many thanks for the post. I also have a mac with M3 Max and followed the posted steps to install OpenFOAM 5.0, but got an error "symbol not found in flat namespace '_ompi_mpi_byte'". Then followed this link https://github.com/mrklein/openfoam-os-x/issues/91
Now it seems working well. |
|
April 2, 2024, 06:22 |
|
#10 |
New Member
Kevin Nolan
Join Date: Nov 2012
Posts: 13
Rep Power: 14 |
Good stuff, I had posted there also but hadn't followed up.
I also need to install the Foundation version so that is very helpful to know. Thank you. |
|
April 2, 2024, 07:41 |
|
#11 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Quote:
Edit: I can confirm that v11 works fine with the above method. I have tested both serial and parallel tutorial cases. Perhaps a bit more extensive testing is needed though, but it seems promising Last edited by Simbelmynė; April 6, 2024 at 08:21. |
||
April 11, 2024, 07:58 |
|
#12 |
New Member
Marius
Join Date: Sep 2022
Posts: 27
Rep Power: 4 |
Did someone compare the times with running Docker on macOS? Would be interesting to know the difference in performance. I am currently running it on docker with my M1 Max.
|
|
April 11, 2024, 11:40 |
|
#13 |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
I have posted results in the benchmark thread for M1 Max using native (Gerlero) compilation. You could compare your Docker results to those.
|
|
May 8, 2024, 07:48 |
|
#14 |
New Member
Join Date: Dec 2019
Posts: 5
Rep Power: 6 |
hello, I have this error every Time I try to install on Mac Pro M3, Mac suggests to install
command line developer tools and I click install it, however it keeps the error and the installation fails. xcode-select: Failed to locate 'm4', requesting installation of command line developer tools. m4 stage failed on expressions/fields/fieldExprLemonParser.lyy-m4 Retaining intermediate: /Users/mohammedshahin/OpenFOAM22/OpenFOAM-v2206/build/darwin64ClangDPInt32Opt/src/OpenFOAM/expressions/fields/fieldExprLemonParser.lyy make: *** [/Users/mohammedshahin/OpenFOAM22/OpenFOAM-v2206/build/darwin64ClangDPInt32Opt/src/OpenFOAM/expressions/fields/fieldExprLemonParser.o] Error 1 make: *** Waiting for unfinished jobs.... |
|
May 8, 2024, 09:02 |
|
#15 |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
More information is needed.
This problem can be associated with multiple installations of OF (Gerlero and other). Try to remove config files for OpenFOAM in your user directory |
|
August 6, 2024, 14:54 |
|
#16 |
Member
Hyun Ko
Join Date: Jun 2009
Posts: 35
Rep Power: 17 |
Hello Kolan,
I have followed your instruction to compile and install OF2206. After compilation and decomposing a mesh, I got a following error. ================================================== = --> FOAM FATAL ERROR: (openfoam-2206) Attempted to use <scotch> without the scotchDecomp library loaded. This message is from the dummy scotchDecomp stub library instead. Please install <scotch> and ensure libscotch.so is in LD_LIBRARY_PATH. The scotchDecomp library can then be built from src/parallel/decompose/scotchDecomp. Dynamically loading or linking this library will add <scotch> as a decomposition method. ================================================== = Do you have any idea for this error? As per your instruction, I have edited etc/config.sh/scotch file. ================================================== = #------------------------------------------------------------------------------ # USER EDITABLE PART: Changes made here may be lost with the next upgrade #SCOTCH_VERSION=scotch_6.1.0 #export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/ #platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_ OPTION/$SCOTCH_VERSION export SCOTCH_VERSION=scotch-system export SCOTCH_ARCH_PATH=/opt/homebrew/Cellar/scotch/7.0.4 # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ ================================================== = thank you. |
|
September 10, 2024, 12:13 |
video on compilation of OpenFOAM-v2406 from source on MacOS
|
#17 |
Member
Hosein
Join Date: Nov 2011
Location: Germany
Posts: 94
Rep Power: 15 |
Thanks for all the contributions! As they say a picture is worth a thousand words, a video is worth even more . Just in case if someone is still struggling, this video may help : https://youtu.be/_z7K97NE2pg
compilation done on M1 apple silicon with macOS Monterey |
|
September 10, 2024, 14:09 |
|
#18 |
New Member
Kevin Nolan
Join Date: Nov 2012
Posts: 13
Rep Power: 14 |
Hi hyunko,
What does Code:
% brew info scotch My system is currently reporting: Code:
==> scotch: stable 7.0.5 (bottled), HEAD Package for graph partitioning, graph clustering, and sparse matrix ordering https://gitlab.inria.fr/scotch/scotch Installed /opt/homebrew/Cellar/scotch/7.0.5 (231 files, 11.2MB) * Poured from bottle using the formulae.brew.sh API on 2024-08-15 at 16:26:11 From: https://github.com/Homebrew/homebrew...la/s/scotch.rb License: CECILL-C ==> Dependencies Build: bison ✘ Required: open-mpi ✔ ==> Options --HEAD Install HEAD version ==> Analytics install: 86 (30 days), 147 (90 days), 553 (365 days) install-on-request: 84 (30 days), 143 (90 days), 544 (365 days) build-error: 0 (30 days) |
|
September 10, 2024, 23:52 |
|
#19 |
Member
Hyun Ko
Join Date: Jun 2009
Posts: 35
Rep Power: 17 |
Thank you Kolan.
I successfully compiled OF with following instruction. https://github.com/mrklein/openfoam-...ase-&-Homebrew |
|
September 16, 2024, 18:43 |
cfMesh tools
|
#20 | |
New Member
Join Date: Sep 2024
Posts: 1
Rep Power: 0 |
Quote:
BTW, You have made it very nice and easy to get up and going with OpenFoam! Thanks |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM.com] Native OpenFOAM for macOS: OpenFOAM-v2112.app (install instructions and GitHub link) | gerlero | OpenFOAM Installation | 32 | November 21, 2024 03:20 |
Frequently Asked Questions about Installing OpenFOAM | wyldckat | OpenFOAM Installation | 3 | November 14, 2023 12:58 |
[Other] Basic questions about OpenFOAM cluster running and installing | Fauster | OpenFOAM Installation | 0 | May 25, 2018 16:00 |
[OpenFOAM.com] Issues with installing v1712 on MacOS | Spacegirl1923 | OpenFOAM Installation | 8 | April 12, 2018 18:44 |
Suggestion for a new sub-forum at OpenFOAM's Forum | wyldckat | Site Help, Feedback & Discussions | 20 | October 28, 2014 10:04 |