Running NuPIC on Raspberry Pi...having problems

Has anyone tried recently tried running NuPIC on a Raspberry Pi?

I’ve been following the guide: https://github.com/numenta/nupic/wiki/Running-NuPIC-on-Raspberry-Pi
And also, https://github.com/numenta/nupic/wiki/Installing-NuPIC-on-Ubuntu
And the NuPIC guide for 15.10 Ubuntu install:
https://www.youtube.com/watch?v=rN-57iBvcT4

I have a Raspberry Pi 3 model B. I ran into some issues.
python setup.py install --user didn’t work, I think one of the errors that popped up said something about the CPU not being compatible.
I think that NuPIC bindings install from the amazon server (or maybe it was the wheels installation) doesn’t work because it’s not supported on Raspberry Pi.

1 Like

This guide is very obsolete. NuPIC has changed a lot since it was written.

As far as I know, no one has run NuPIC on a Raspberry Pi in over a year. I tried it over year ago with the B came out, but failed a lot before giving up. It’s not as easy as following the Ubuntu instructions because you have to identify, package, and include a bunch of 32b C++ libraries during the build.

You’ll have to build it from source yourself since there are no binary packages for ARM. I’ve successfully nupic from source before (not on raspberry pi), so I might be able to help if you need.

Yea, help would be nice. I don’t even know where to start on this one…

Make sure you’ve got the required package dependencies on your rpi.

  • Download and build nupic.core
  • Download and build nupic

Post any error messages you get. The build system for the nupic stuff is reasonably robust now.

1 Like

This is after I’ve tried installing all the required packages.

nupic.core installation:
$ pip install nupic.bindings
Collecting nupic.bindings
  Could not find a version that satisfies the requirement nupic.bindings (from versions: )
No matching distribution found for nupic.bindings
-------------------------------------------------

$ python setup.py install
-- The CXX compiler identification is GNU 4.9.2
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- NUPIC_BUILD_PYEXT_MODULES = ON
-- PY_EXTENSIONS_DIR         = /home/pi/nupic.core/bindings/py/nupic/bindings
Doing a local build
-- CMAKE_CXX_COMPILER_ID = GNU
-- CMAKE_C_COMPILER      = 
-- CMAKE_CXX_COMPILER    = /usr/bin/c++
-- CMAKE_BUILD_TYPE      = 
-- CMAKE_INSTALL_PREFIX  = /tmp/tmp34u62P/release
-- CMAKE BITNESS=32
-- CMAKE MEMORY=864
CMake Warning at CommonCompilerConfig.cmake:134 (message):
  Less than 1GB of memory available, compilation may run out of memory!
Call Stack (most recent call first):
  CMakeLists.txt:89 (include)


GNU gold (GNU Binutils for Raspbian 2.25) 1.11
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
Using ld.gold as LINKER.
-- Performing Test compiler_supports_machine_option
-- Performing Test compiler_supports_machine_option - Failed
-- INTERNAL_CXX_FLAGS_OPTIMIZED=  -fvisibility=hidden  -shared-libgcc -fdiagnostics-show-option -marm -fPIC   -static-libstdc++ -std=c++11 -fvisibility-inlines-hidden  -Werror -Wextra -Wreturn-type -Wunused -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -Wall -pipe  -O2 -fuse-ld=gold -fuse-linker-plugin -flto-report -flto
-- INTERNAL_LINKER_FLAGS_OPTIMIZED=  -marm  -shared-libgcc  -static-libstdc++ -Wl,--no-undefined -O2  -flto
-- EXTERNAL_C_FLAGS_UNOPTIMIZED=  -fvisibility=hidden  -shared-libgcc -fdiagnostics-show-option -marm -fPIC  -Wno-unused-variable -Wno-unused-parameter -Wno-incompatible-pointer-types -Wno-deprecated-declarations
-- EXTERNAL_C_FLAGS_OPTIMIZED=  -fvisibility=hidden  -shared-libgcc -fdiagnostics-show-option -marm -fPIC  -Wno-unused-variable -Wno-unused-parameter -Wno-incompatible-pointer-types -Wno-deprecated-declarations -pipe  -O2 -fuse-ld=gold -fuse-linker-plugin -flto-report -flto
-- PYEXT_LINKER_FLAGS_OPTIMIZED=  -marm  -shared-libgcc  -static-libstdc++ -O2  -flto -Wl,--allow-shlib-undefined
-- EXTERNAL_CXX_FLAGS_UNOPTIMIZED=  -fvisibility=hidden  -shared-libgcc -fdiagnostics-show-option -marm -fPIC  -Wno-unused-variable -Wno-unused-parameter -Wno-incompatible-pointer-types -Wno-deprecated-declarations   -static-libstdc++ -std=c++11 -fvisibility-inlines-hidden
-- EXTERNAL_CXX_FLAGS_OPTIMIZED=  -fvisibility=hidden  -shared-libgcc -fdiagnostics-show-option -marm -fPIC  -Wno-unused-variable -Wno-unused-parameter -Wno-incompatible-pointer-types -Wno-deprecated-declarations   -static-libstdc++ -std=c++11 -fvisibility-inlines-hidden -pipe  -O2 -fuse-ld=gold -fuse-linker-plugin -flto-report -flto
-- EXTERNAL_LINKER_FLAGS_UNOPTIMIZED=  -marm  -shared-libgcc  -static-libstdc++ -Wl,--no-undefined
-- EXTERNAL_LINKER_FLAGS_OPTIMIZED=  -marm  -shared-libgcc  -static-libstdc++ -Wl,--no-undefined -O2  -flto
-- COMMON_COMPILER_DEFINITIONS=-DHAVE_UNISTD_H
-- COMMON_COMPILER_DEFINITIONS_STR= -DHAVE_UNISTD_H
-- EXTERNAL_STATICLIB_CMAKE_DEFINITIONS_OPTIMIZED=-DCMAKE_AR:PATH=gcc-ar;-DCMAKE_RANLIB:PATH=gcc-ranlib
-- EXTERNAL_STATICLIB_CONFIGURE_DEFINITIONS_OPTIMIZED=AR=gcc-ar;RANLIB=gcc-ranlib
-- CapnProto CXX_FLAGS=  -fvisibility=hidden  -shared-libgcc -fdiagnostics-show-option -marm -fPIC  -Wno-unused-variable -Wno-unused-parameter -Wno-incompatible-pointer-types -Wno-deprecated-declarations   -static-libstdc++ -std=c++11 -fvisibility-inlines-hidden  -DHAVE_UNISTD_H
-- MERGE_STATIC_LIBRARIES LIB_TARGET=capnp-bundle, STATIC_LIBS = /tmp/tmp34u62P/scripts/ThirdParty/Install/lib/libcapnpc.a;/tmp/tmp34u62P/scripts/ThirdParty/Install/lib/libcapnp.a;/tmp/tmp34u62P/scripts/ThirdParty/Install/lib/libkj.a
-- MERGE_STATIC_LIBRARIES LIB_TARGET=apr-1-bundle, STATIC_LIBS = /tmp/tmp34u62P/scripts/ThirdParty/Install/Apr1StaticLib/lib/libapr-1.a
-- MERGE_STATIC_LIBRARIES LIB_TARGET=aprutil-1-bundle, STATIC_LIBS = /tmp/tmp34u62P/scripts/ThirdParty/Install/AprUtil1StaticLib/lib/libaprutil-1.a
-- MERGE_STATIC_LIBRARIES LIB_TARGET=yaml-bundle, STATIC_LIBS = /tmp/tmp34u62P/scripts/ThirdParty/Build/YamlStaticLib/libyaml.a
-- MERGE_STATIC_LIBRARIES LIB_TARGET=yaml-cpp-bundle, STATIC_LIBS = /tmp/tmp34u62P/scripts/ThirdParty/Install/YamlCppStaticLib/lib/libyaml-cpp.a
-- MERGE_STATIC_LIBRARIES LIB_TARGET=z-bundle, STATIC_LIBS = /tmp/tmp34u62P/scripts/ThirdParty/Install/ZStaticLib/lib/libz.a
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.9", minimum required is "2.7") 
-- CMAKE Found python interpreter /usr/bin/python2.7 version=2.7.9
-- src_numpy_core   = /usr/local/lib/python2.7/dist-packages/numpy/core
-- CMAKE_PREFIX_PATH   = /home/pi/nupic.core/external/common/;/home/pi/nupic.core/external/linux32/;/usr/local/lib/python2.7/dist-packages/numpy/core/
fatal: Not a git repository (or any of the parent directories): .git
-- Found PythonLibs: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (found version "2.7.9") 
-- PYTHON_EXECUTABLE   = /usr/bin/python2.7
-- PYTHON_INCLUDE_DIRS = /usr/include/python2.7
-- PYTHON_LIBRARIES    = /usr/lib/arm-linux-gnueabihf/libpython2.7.so
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named capnp
CMake Error at src/CMakeLists.txt:225 (message):
  ERROR: getting capnproto headers location (1)


-- Configuring incomplete, errors occurred!
See also "/tmp/tmp34u62P/scripts/CMakeFiles/CMakeOutput.log".
See also "/tmp/tmp34u62P/scripts/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "setup.py", line 58, in <module>
    
  File "/home/pi/nupic.core/bindings/py/setup.py", line 201, in <module>
    getExtensionFiles(platform)
  File "/home/pi/nupic.core/bindings/py/setup.py", line 166, in getExtensionFiles
    generateExtensions()
  File "/home/pi/nupic.core/bindings/py/setup.py", line 184, in generateExtensions
    "-DPY_EXTENSIONS_DIR={}".format(pyExtensionsDir)])
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/home/pi/nupic.core', '-DCMAKE_INSTALL_PREFIX=/tmp/tmp34u62P/release', '-DPY_EXTENSIONS_DIR=/home/pi/nupic.core/bindings/py/nupic/bindings']' returned non-zero exit status 1

--------------------------------------------------

from nupic installation:

~/nupic $ pip install nupic
Collecting nupic
  Downloading nupic-0.5.7-py2-none-any.whl (4.8MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4.8MB 48kB/s 
Collecting pyproj==1.9.3 (from nupic)
  Downloading pyproj-1.9.3.tar.gz (2.7MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2.7MB 86kB/s 
Requirement already satisfied: pytest==2.5.1 in /usr/local/lib/python2.7/dist-packages (from nupic)
Collecting asteval==0.9.1 (from nupic)
  Downloading asteval-0.9.1.tar.gz
Collecting mock==1.0.1 (from nupic)
  Downloading mock-1.0.1.zip (861kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 870kB 238kB/s 
Requirement already satisfied: numpy==1.11.2 in /usr/local/lib/python2.7/dist-packages (from nupic)
Collecting validictory==0.9.1 (from nupic)
  Downloading validictory-0.9.1.tar.gz
Collecting DBUtils==1.1 (from nupic)
  Downloading DBUtils-1.1.tar.gz (109kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 112kB 632kB/s 
Requirement already satisfied: pytest-xdist==1.8 in /usr/local/lib/python2.7/dist-packages (from nupic)
Collecting pycapnp==0.5.8; platform_system == "Linux" or platform_system == "Darwin" (from nupic)
  Downloading pycapnp-0.5.8.tar.gz (449kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 450kB 365kB/s 
Requirement already satisfied: pytest-cov==1.6 in /usr/local/lib/python2.7/dist-packages (from nupic)
Collecting PyMySQL==0.6.2 (from nupic)
  Downloading PyMySQL-0.6.2-py2.py3-none-any.whl (63kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 71kB 987kB/s 
Collecting ordereddict==1.1 (from nupic)
  Downloading ordereddict-1.1.tar.gz
Collecting unittest2==0.5.1 (from nupic)
  Downloading unittest2-0.5.1.zip (78kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 81kB 983kB/s 
Collecting nupic.bindings==0.4.13 (from nupic)
  Could not find a version that satisfies the requirement nupic.bindings==0.4.13 (from nupic) (from versions: )
No matching distribution found for nupic.bindings==0.4.13 (from nupic)
--------------------------------

You need to build nupic.core and install the nupic.bindings package from there.

Oh, I thought that I already tried that.
What command should I run to build nupic.core?

Okay, I think the installation worked, I run all the tests and they seem to have all checked out. I succeeded by first of all installing a 2GB swap space, and second of all, by carefully installing every dependency and every requirement on each dependency and perhaps even a couple more dependencies that I don’t need. I also tried to follow each instruction more carefully and I used β€œβ€“user” and β€œsudo” a lot more, to make sure it actually lets me install. Here’s a URL of the gist (raw output) of some of the installation that went into nupic.core, in case you want to check for anything bad that went wrong. Log of some of the installation of nupic.core.

Anyway, I still can’t use NuPIC on my Raspberry Pi for what I wanted to use it for…like swarming and/or anomaly detection. I tried installing nupic using β€œpip install nupic” which didn’t work since it complained about not having the correct distribution of nupic.bindings==0.4.13 but when I did β€œpython setup.py install --user” in the nupic directory, it worked. Sidenote: I think all of the following commands work or at least supposed to work on my non-Pi PC machine (so there is probably nothing wrong with the commands/files themselves). But probably some libraries are somehow missing.

Here are the errors I see:

pi@daedalus:~/nupic/examples/opf/clients/hotgym/prediction/one_gym $ ./swarm.py
./swarm.py: line 24: $'\nGroups together the code dealing with swarming.\n(This is a component of the One Hot Gym Prediction Tutorial.)\n': command not found
./swarm.py: line 25: import: command not found
./swarm.py: line 26: import: command not found
./swarm.py: line 29: import: command not found
./swarm.py: line 32: syntax error near unexpected token `from'
./swarm.py: line 32: `from nupic.swarming import permutations_runner'

pi@daedalus:~/nupic/examples/opf/clients/hotgym/prediction/one_gym $ python swarm.py
Traceback (most recent call last):
  File "swarm.py", line 32, in <module>
    from nupic.swarming import permutations_runner
ImportError: No module named swarming

pi@daedalus:~/nupic/examples/opf/clients/hotgym/prediction/one_gym $ python run.py
Traceback (most recent call last):
  File "run.py", line 30, in <module>
    from nupic.data.inference_shifter import InferenceShifter
ImportError: No module named data.inference_shifter

pi@daedalus:~/nupic/examples/opf/clients/hotgym/prediction/test1 $ ./process_input.py 101m.csv 101-output-test1.csv -1 OFF Vals
Traceback (most recent call last):
  File "./process_input.py", line 28, in <module>
    from nupic.frameworks.opf.modelfactory import ModelFactory
ImportError: No module named frameworks.opf.modelfactory
2 Likes

Try installing nupic from source now, which requires: nupic.bindings==0.4.16. Checkout the tag in the nupic.core repository directory on our rpi:

$ git checkout tags/0.4.16

Then build and install nupic.core again, then build nupic from source.

Anyway, I highly advise you use pyenv or at least virtualenv to manage what version of python you have installed.

Okay I just did all of that. The builds and installations didn’t seem to give me any errors but some of the tests failed for nupic. So I still can’t run swarms or prediction, I get the same kind of errors as I’ve listed in my previous post. I wonder if it has something to do with the fact that I’ve installed using β€œβ€“user” and not "sudo."
Here are some of the tests that I ran, I put it up on gist.

So should I start a new thread about this?

@addonis I’m willing to help you with this (I have a raspberry pi laying around). But it will have to be at least next week (or the week after). Please remind me?? I have some catching up to do after the holidays.

Cool, I’ll remind you after

Can we do it this week? :sunny:

:frowning2: probably not

Okay, so I got this error fixed. When I ran the command python run.py you can see that there is no file in nupic/frameworks/opf/modelfactory as well as some other files. So to fix the error, some files have to be moved around. The files are there (in the nupic directory), you just have to find them and put them into places as to let other python files know about them. So now I can run a swarm (swarm.py) on the hot_gym demo on the Raspberry Pi, and I can also run a prediction model (run.py) with the swarmed data.
Although my file is still not working, it says:

pi@daedalus:~/nupic/examples/opf/clients/hotgym/prediction/test1 $ ./process_input.py 101m.csv 101-output-test1.csv -1 OFF Vals

ERR: Unknown parameter 'maxBoost' for region 'SP' of type 'py.SPRegion'
Valid parameters are:
   stimuluisThreshold 
   columnCount
....
....(etc.)
Traceback calls (too much to write out, and I was having trouble copying it to a USB).
RuntimeError: Unknown parameter 'maxBoost' for region 'SP' of type 'py.SPRegion'
Valid parameters are:
   stimuluisThreshold 
   columnCount
....
....(etc.)

Outstanding! You are well on the way!

This error probably means that the client code you are running is old. NuPIC changed maxBoost to boostFactor recently. @ycui am I right about that?

@Addonis Did you fix your problem?