Compiling NuPIC on Ubuntu 15

Matthew Taylor edited this page Feb 18, 2016 · 9 revisions
Clone this wiki locally

Setup

Install some basic depedencies

sudo apt-get update -y
sudo apt-get install git cmake python-dev -y

Clone nupic.core and nupic

git clone https://github.com/numenta/nupic.core.git
git clone https://github.com/numenta/nupic.git

Set some environment vars

These point to our checkout directories. We'll need them later for running tests and scripts. (You'll probably want this in your .bashrc or .bash_profile.)

export NUPIC=$HOME/nupic
export NUPIC_CORE=$HOME/nupic.core

Get the latest pip

Notice we are not using apt-get because it provides a very old version of pip that is hard to update properly.

curl https://bootstrap.pypa.io/get-pip.py | sudo python

Downgrade to GCC 4.9

Ubuntu 15 comes with GCC 5.2, which doesn't yet work with NuPIC.

sudo apt-get install gcc-4.9 g++-4.9 -y

Now gcc/g++ 4.9 is installed, but not the default. We'll use the update-alternatives method to properly set up both compiler versions, making it easy to switch between them. See this article for a good explanation.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20

Now we switch both gcc and g++ to 4.9:

> sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-4.9   20        auto mode
  1            /usr/bin/gcc-4.9   20        manual mode
  2            /usr/bin/gcc-5     10        manual mode

Simply input 1 or hit return. Now you should be using gcc 4.9:

> gcc --version
gcc (Ubuntu 4.9.3-5ubuntu1) 4.9.3

Do the same for g++:

> sudo update-alternatives --config g++
There are 2 choices for the alternative g++ (providing /usr/bin/g++).

  Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/g++-4.9   20        auto mode
  1            /usr/bin/g++-4.9   20        manual mode
  2            /usr/bin/g++-5     10        manual mode

Press <enter> to keep the current choice[*], or type selection number: 
> g++ --version
g++ (Ubuntu 4.9.3-5ubuntu1) 4.9.3

NuPIC Core

Install nupic.core python dependencies

This takes awhile because numpy!

cd $NUPIC_CORE
pip install -r bindings/py/requirements.txt --user

Install pycapnp

This will install the python Capnproto bindings and the C++ Capnproto program.

pip install pycapnp --user

Configure and generate C++ build files

See the README for details about the following commands.

mkdir -p $NUPIC_CORE/build/scripts
cd $NUPIC_CORE/build/scripts
cmake $NUPIC_CORE -DCMAKE_INSTALL_PREFIX=../release -DPY_EXTENSIONS_DIR=$NUPIC_CORE/bindings/py/nupic/bindings

Build

Note: The -j3 option specifies '3' as the maximum number of parallel jobs/threads that Make will use during the build in order to gain speed. However, you can increase this number depending your CPU.

make -j3

explode

collect2: error: ld returned 1 exit status
src/CMakeFiles/connections_performance_test.dir/build.make:99: recipe for target 'src/connections_performance_test' failed
make[2]: *** [src/connections_performance_test] Error 1
CMakeFiles/Makefile2:334: recipe for target 'src/CMakeFiles/connections_performance_test.dir/all' failed
make[1]: *** [src/CMakeFiles/connections_performance_test.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
make: *** [all] Error 2

Full console output.





Install

Stay in the $NUPIC_CORE/build/scripts directory.

make install

NuPIC