Nupic.engine problem with numpy

I have been using the docker nupic image (on Ubuntu 18.10, 64 bit) happily for some time.
To-date I have been doing experiments using encoders, SPs, TMs, Classifiers using the Algorithms approach, which is all fine.

Today I tried using the Network API, but I cannot get anywhere with it because as soon as I get to

from nupic.engine import Network 

I get the following error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  initializeNumpy: numpy.core.multiarray failed to import.
Aborted (core dumped)

PS In case it is relevant, I also previously did:

pip install htmresearch

Any ideas as to how to diagnose/fix this?

This seems like a numpy version problem. Perhaps htmresearch required a newwer version of numpy that nupic.engine? Investigate how many versions of numpy you have installed, and try uninstalling all but one.

I only have numpy 1.12.1 installed:

# pip show numpy
Name: numpy
Version: 1.12.1
Summary: NumPy: array processing for numbers, strings, records, and objects.
Home-page: http://www.numpy.org
Author: NumPy Developers
Author-email: numpy-discussion@scipy.org
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires: 
Required-by: scipy, pyqtgraph, plyfile, pandas, matplotlib, htmresearch, gensim, nupic.bindings, nupic

I have looked at the version dependencies (in the requirements.txt file) of both nupic and htmresearch and they both say numpy version 1.12.1 which is what I’ve got.

numpy is still working fine when called from the code I previously developed, but not with the Network API. As I said before this fails on the line:

from nupic.engine import Network 

(I know this because I can put this one line in program on its own and execute it - which fails.)

I note that the first thing nupic.engine does is call nupic.bindings – I think this may be where the problem is? (I do not have the programming skills to understand the SWIG interface to C.) I note in the HTM forum others have had problems installing nupic.bindings, and your advice has been to rebuild it from source but I do not know how to do this?

Is there another docker image available that has both nupic and htmresearch installed (and working!)?

If you are trying to get htmresearch code to work, you don’t want to use the nupic.engine docker image. That is tied to a very old version of nupic.

There is no docker image for htmresearch online, but you could either start with dockerhub/nupic, or just a plain python image and pip install nupic htmresearch. (thanks @lscheinkman)

Sorry, I think we are talking at cross purposes, I am not using a nupic.engine docker image (I did not know there was one).

I am using dockerhub/nupic to which I then did pip install htmresearch from inside the container.

I will try your suggestion of starting with a python image and then pip install nupic htmresearch – however I am worried that this still might not work due to the nupic.bindings to C?

Sorry I think I misread you. I thought you were using an image of “htm engine”.

I’m not sure why running pip install htmresearch would not work on top of the nupic dockerhub image.

Creating a new docker image from the docker image of python:2.7 as you suggested then pipping nupic and htmresearch seems to work - thanks.

1 Like