Building NEST on macOS¶
Building NEST on macOS requires some developer tools. There are several sources from which you can install them, e.g., Conda, Homebrew, or MacPorts. The most important recommendation for an easy and stable build is not to mix tools from different sources. This includes your Python installation: Taking Python from Conda and all else from Homebrew may work, but can also lead to various complications.
This guide shows how to build NEST with a development environment created with Conda. The main
advantage of Conda is that you can fully insulate the entire environment in a Conda environment.
If you want to base your setup on Homebrew or MacPorts, you can still use the
environment.yml file as a guide to necessary packages.
Install the Xcode command line tools by executing the following line in the terminal and following the instructions in the windows that will pop up:
Create a conda environment with necessary tools (see also Tips for installing NEST with conda)
cd <nest_source_dir> conda env create -p conda/
To build NEST natively on a Mac with Apple’s M1 chip, you need to use Miniforge as described in Tips for installing NEST with conda.
Activate the environment with
conda acvitate conda/
This assumes that you have created the environment in the folder
conda/as given above. Note that the trailing slash is necessary for conda to distinguish it from a named environment.
If you want to build NEST with MPI, you must digitally sign the
If you do not yet have a self-signed code-signing certificate, create one as described here: https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html (restarting does not appear to be necessary any more).
Sign your binaries
codesign -f -s "gdb-cert" `which orted` codesign -f -s "gdb-cert" `which orterun`
Instead of the
whichcommand you can also give the full path to the binary inside your conda environment.
You will need to sign the binaries every time you update the OpenMPI package in your environment.
Download or clone the NEST sources from https://github.com/nest/nest-simulator.
Create a build directory outside the NEST sources and change into it.
Configure NEST by running
cmake -DCMAKE_INSTALL_PREFIX:PATH=<nest_install_dir> <nest_source_dir>
If you have libraries required by NEST such as GSL installed with Homebrew and Conda, this can lead to library conflicts (error messages like
Initializing libomp.dylib, but found libomp.dylib already initialized.). To ensure that libraries are found first in your conda environment, invoke
CMAKE_PREFIX_PATH=<conda_env_dir> cmake -DCMAKE_INSTALL_PREFIX:PATH=<nest_install_dir> <nest_source_dir>
You can find the
<conda_env_dir>for the currently active conda environment by running
conda infoand looking for the “active env location” entry in the output.
Compile, install, and verify NEST with
make -j4 # -j4 builds in parallel using 4 processes make install make installcheck
To run NEST, configure your environment with
Installing into a virtual environment¶
You can install NEST to the default location for Python packages inside a virtual environment by activating the virtual environment before building NEST, by modifying the instructions above as follows:
Create the virtual environment if it does not exist yet (replace
nest_envby a name of your choice)
Activate the environment
Navigate to your NEST build directory
Configure NEST by running
Build and install NEST as described above
If you follow this approach, you do not need to source
nest_vars.sh, as the Python package
for NEST is installed in a default location.
Conda with Intel MKL¶
A default installation of Anaconda or Miniconda will install a version of NumPy
built on the Intel Math Kernel Library (MKL). This library uses a different OpenMP
library to support threading than what’s included with Apple Clang or GCC. This will lead
to conflicts if NEST is built with support for threading, which is the default and
usually desirable. One way to avoid this is to follow the instructions above. An
alternative is to create a conda environment in which you install
nomkl as the
very first package. This will tell conda to install MKL-free versions of NumPy and
other linear-algebra intensive packages.