Skip to content

Instantly share code, notes, and snippets.

@abhijit-c
Last active January 6, 2023 16:47
Show Gist options
  • Save abhijit-c/042b7e575024dc9a7578eefd1e509f69 to your computer and use it in GitHub Desktop.
Save abhijit-c/042b7e575024dc9a7578eefd1e509f69 to your computer and use it in GitHub Desktop.

Installing FEniCS-2019 on your Apple Silicon Machine w/ Anaconda

FEniCS is a nice numerical toolbox for solving PDEs through finite element type methods. However, ever since they've begun moving to the new syntax breaking version FEniCSx the installation of the older legacy 2019 FEniCS version has gotten more and more arcane, as dependencies are left frozen. Although it's best to eventually learn the newer version, or to transition to another package (e.g. firedrake), chances are if you're inheriting some code you'll need to be able to run FEniCS-2019.

If you're running more traditional x86 architecture, the original installation instructions should work just fine. However, if you're on the newer macbooks with apple's own in house silicon, the installation instructions haven't been updated for them. FEniCS was develped with x86 in mind, and a lot of the dependencies don't play nicely with apple silicon hardware; hence you need to make some changes.

I recommend anaconda as the installation medium, in my experience the docker based containers for FENiCS suffered huge performance degradation due to the architecture difference. After installing that via the official installation instructions, open a terminal and enter the following commands:

conda create -n fenics2019
conda activate fenics2019
conda config --env --set subdir osx-64
conda install -c conda-forge fenics

Functionally, what this is doing is creating a conda enviornment named fenics2019, activating it for your session, configuring it to use apple's x86 translation layer, and then installing FEniCS. Now if you need additional packages they need to be installed in this enviornment using anaconda's own system. Read the official documentation to figure out how that works, but usually just looking up 'conda matplotlib' and following the first link is sufficient. This cheat sheet is also useful. In the case of matplotloib, running

conda install -c conda-forge matplotlib

while the fenics2019 enviornment is active is all you need to do. You can deactivate the conda enviornment through the command conda deactivate; You'll later need to run conda activate fenics2019 again to run any FEniCS code you have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment