numenta / nupic.core-legacy

Implementation of core NuPIC algorithms in C++ (under construction)
http://numenta.org
GNU Affero General Public License v3.0
272 stars 276 forks source link
NuPIC Logo

As of September 2023 this repository contains code from legacy Hierarchical Temporal Memory (HTM) Numenta projects that have been in maintenance mode for several years.

NuPIC Core Unix-like Build Status Windows Build Status CircleCI Coverage Status

This repository contains the C++ source code for the Numenta Platform for Intelligent Computing (NuPIC). It will eventually contain all algorithms for NuPIC, but is currently in a transition period. For details on building NuPIC within the python environment, please see http://github.com/numenta/nupic.

Installing from a Release

You can install the nupic.bindings Python package from PyPI:

pip install nupic.bindings

Optionally include --user or other flags to determine where the package is installed.

Note: On Linux this will do a source installation and will require that the prerequisites specified below are installed.

Building from Source

Important notes:

Prerequisites

Note: On Windows, Python package dependencies require the following compiler package to be installed: Microsoft Visual C++ Compiler for Python 2.7

The Python dependencies (NumPy and pycapnp) can be installed with pip:

pip install -r bindings/py/requirements.txt

Simple Source Installation (does not support incremental builds)

The easiest way to build from source is as follows. This does not support incremental builds.

python setup.py install

Optionally include --user or other flags to determine where the package is installed.

Testing the Installation

Regardless of how you install nupic.bindings, the nupic-bindings-check command-line script should be installed. Make sure that you include the Python bin installation location in your PATH environment variable and then execute the script:

nupic-bindings-check

Developer Installation

This option is for developers that would like the ability to do incremental builds of the C++ or for those that are using the C++ libraries directly.

Note: The following sub-sections are related to Linux and OSX only. For Windows refer to the external\windows64-gcc\README.md file.

Configure and generate C++ build files:

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

Notes:

Build:

# While still in $NUPIC_CORE/build/scripts
make -j3

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.

Install:

# While still in $NUPIC_CORE/build/scripts
make install

Run the tests:

cd $NUPIC_CORE/build/release/bin
./cpp_region_test
./unit_tests
...

Install nupic.bindings Python library:

cd $NUPIC_CORE
python setup.py develop

Note: If the extensions haven't been built already then this will call the cmake/make process to generate them.

If you get a gcc exit code 1, you may consider running this instead:

 python setup.py develop --user

If you are installing on Mac OS X, you must add the instruction ARCHFLAGS="-arch x86_64" before the python call:

ARCHFLAGS="-arch x86_64" python setup.py develop

Alternatively, you can use the install command (as opposed to develop) to copy the installation files rather than link to the source location.

python setup.py install

Note: If you get a "permission denied" error when using the setup commands above, you may add the --user flag to install to a location in your home directory, which should resolve any permissions issues. Doing this, you may need to add this location to your PATH and PYTHONPATH.

Once it is installed, you can import NuPIC bindings library to your python script using:

import nupic.bindings

You can run the nupic.bindings tests via setup.py:

python setup.py test

Using graphical interface

Generate the IDE solution:

Build:

Run the tests:

Build Documentation

Run doxygen, optionally specifying the version as an environment variable:

PROJECT_VERSION=`cat VERSION` doxygen

The results will be written out to the html directory.