Installing NuPIC on Ubuntu 12

This was tested on Ubuntu 12.04.5 for both 32bit and 64bit and on Ubuntu 14.04 LTS 64bit. There are known problems with Ubuntu 14.10. It assumes you have nothing except what was installed along with the Ubuntu ISO. However, since the creation of this document, there have been changes to the nupic build configuration that invalidates these instructions for 32-bit systems. See Installing NuPIC on Ubuntu 32bit for more information on 32 bit install.

Update apt-get

sudo apt-get update
sudo apt-get upgrade # optional

Install required packages

These may already be installed, depending on your system.

sudo apt-get install git python-dev python-pip automake libtool libssl-dev g++ cmake mysql-server libpcre3-dev

pip install numpy

NOTE: During this installation, you may be prompted to enter a MySQL password for the root user. If you provide your own root password, you will need to update your MySQL settings in the NuPIC configuration file.

  • git: for cloning the NuPIC repository
  • python-dev: to get Python headers for compiling C++ with SWIG
  • python-pip: for python package installation of required NuPIC python dependencies
  • automake: for C++ build
  • libtool: GNU tool for creating portable compiled binaries
  • libssl-dev: encryption libraries
  • g++: GNU C++ compiler
  • cmake: cross-platform, open-source make system
  • mysql-server: Used for swarming
  • libpcre3-dev: Perl Compatible Regular Expressions development library (for SWIG compilation below, only required for 32b systems)
  • numpy: Python math package

NOTE: You may also need to install numpy to get your installation to work. Personally, I used sudo apt-get install numpy since I didn’t know exactly which package caused the install to complain.

Install GCC 4.8

gcc4.8 is required for C++11. You may do this however you like. But here are some instructions for one way of doing it.

** gcc-4.8 is required by NuPIC now ** and it is also default on most Ubuntu systems (14.04 LTS +)

  1. sudo add-apt-repository ppa:ubuntu-toolchain-r/test
  2. sudo apt-get update
  3. sudo apt-get install gcc-4.8 g++-4.8
  4. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
  5. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
  6. sudo update-alternatives --config gcc (Choose the option for the new 4.8 compiler)

Clone the NuPIC repo

Change to the directory where you want to keep the nupic repo:

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

This will create a nupic directory containing the NuPIC source code in the current directory.

Set the NUPIC environment variable

export NUPIC=$PWD/nupic

Build NuPIC

python setup.py install --user

Troubleshooting

If you have problems with the python setup.py install command, try cleaning out your local checkout by running git clean -dfx. WARNING: This will clear out any local files that are not controlled by git.

Not enough memory for compilation

If you run in VM (or on a system with quite low RAM), for compilation it seems the gcc requires atleast 2GB RAM memory, otherwise you can see errors like in this thread

1 Like

On Ubuntu 18.04 when running:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6

it gives error:

update-alternatives: error: alternative path /usr/bin/gcc-4.6 doesn't exist

But even without running those 3 commands installing NuPIC seems to work fine.

1 Like

Probably because 18 comes with newer compilers that work fine. Thanks for the note. I have not tried NuPIC in Ubuntu in a long time.