I’ve recently run into the problem of trying to compile the source for NEURON 7.3a that includes support for parallel NEURON (using MPI) and Python on Mac OS X Lion. Using a number of helpful web resources, I wanted to cobble together an “as-of-this-writing” practice to get a kitchen sink working install for all components.
UPDATED 01-Sept-2012: Added instructions for mpi4py
Because I don’t have the resources to test many version combinations, etc., this assumes OS X 10.7.4 on a Retina MacBook Pro 10,1 (Mid 2012), with a working copy of XCode 4.4.1 installed (available for free from the Mac App Store). I suspect but cannot verify that this will work with many different versions of all of these components. Note: MacPorts is particularly sensitive to very new XCode and OS releases, so right after a new one, things don’t always work right away.
Finally this assumes you have admin access to the computer on which you are installing things and that you will use
sudo for good and not evil.
And super-finally, this is basically an aggregate of web sources, some of which I had to modify to get it working. Sources are inline, below. Much is duplicated here because of the transience of web links.
$ sudo port install python27 $ sudo port install py27-numpy $ sudo port install py27-scipy $ sudo port select python python27
$ which python
should result in: ‘/opt/local/bin/python’.
3. Now install the message passing interface (MPI) components. On Mountain Lion (10.8.x), I’ve only gotten OpenMPI working, and only from source (and not MacPorts). But on Lion, I’ve gotten MPICH2 working from MacPorts to play nicely with Neuron (sudo port install mpich2). However here are instructions for how to install MPICH2 from source, with these minimal steps:
a. Download MPICH2 from this website. Look for an
http link. Do not worry about Hydra unless you know why (and don’t forget to tell me).
b. In the terminal, follow these commands2,3,4:
$ cd ~/Downloads $ tar xvzf mpich2-X.x.tar.gz $ cd mpich2-X.x $ ./configure $ make $ sudo make install
It installs in /usr/local/bin, which you can verify by running: “which mpicc”. (MacPorts version installs in /opt/local/bin by default.)
4a. Download the latest NEURON. Get both InterViews (IV) and NEURON (nrn) and issue the following commands in a terminal window3,5:
$ mkdir ~/Downloads/neuron $ mv ~/Downloads/iv-XX.tar.gz ~/Downloads/neuron/ $ mv ~/Downloads/nrn-X.X.tar.gz ~/Downloads/neuron/ $ cd ~/Downloads/neuron $ tar xvzf iv-XX.tar.gz $ tar xvzf nrn-X.X.tar.gz
4b. Compile and install InterViews:
$ IDIR=/Applications/NEURON-X.X $ cd iv-XX/ $ ./configure --prefix=$IDIR/iv $ make $ sudo make install
4c. Compile and install NEURON with python and MPI support:
5. Add the new NEURON directory to your PATH variable. If you are using the bash shell (often default), edit the file ~/.bashrc by adding or modifying a line that looks like:
ARCH is most often one of i386, i686, or x86_64 and can be found in the terminal by going to
/Applications/NEURON-X.X and looking for one of these.
6. You need to build in support to run NEURON as a module:
$ cd ~/Downloads/neuron/nrn-X.X/src/nrnpython/ $ sudo python setup.py install
This can be tested:
$ python >>> from neuron import h
That last statement should not complain at you. Instructions on how to start NEURON with python and vice versa are found on this website.
7. Now, let’s install mpi4py, which is necessary for letting Python handle MPI. I could not get the MacPorts py27-mpi4py package working, but it works from source. It’s important that the right python is run on this command and that it knows where mpicc lives.
a. Download the mpi4py source from here.
b. Now unzip and compile here:
$ tar xvzf mpi4py-x.x $ cd mpi4py-x.x $ python setup.py build --mpicc=/usr/local/bin/mpicc $ sudo python setup.py install
Per the installation instructions in mpi4py, this can all be tested:
$ cd demo $ mpiexec -n 5 python helloworld.py
This should also have reasonable output. Please leave comments if certain aspects worked or did not work or if anything here needs clarification!
2 Assumes that the file downloaded to your
~/Downloads/folder (often defaults here)
3 Please, replace the X’s with the version number that you downloaded, such as ‘1.6’ or ‘1.4.3’
4 You may need to issue the command
'sudo make all'instead of
5 The trailing ‘/’ may be important. For safety sake, just include it.