Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does scikit-learn cause core dumped?

I try to run a simple linear fit in scikit-learn:

from sklearn import linear_model
clf = linear_model.LinearRegression()
clf.fit ([[0, 0], [1, 1], [2, 2]], [0, 1, 2])

As a result I get:

Illegal instruction (core dumped)

Does anybody know what is the reason of this problem and how the problem can be resolved?

P.S. I use the version 0.16.1 of scikit-learn. But I had this problem also with an older version. I do it under Ubuntu.

ADDED

Today I have tried another estimator (KernelRidge) and I got the same error message. I think that several month ago I tried to solve a system of linear equations using scipy and I had the same error. I need to add that examples that I tried were always small (so, the size of the problem should not be the reason of the error). On other computer (at work) I also have Ubunutu and use scikit-learn and I do not have their this problem. So, it looks like I have some problem with my home laptop.

like image 855
Roman Avatar asked May 25 '15 14:05

Roman


1 Answers

Going out on a limb here, but does your laptop by any chance have an AMD CPU?

AMD have removed support for the 3DNow! instructions from their more recent processors (source), which a trawl of Ubuntu and Debian bugtrackers shows that many people are being hit by (eg 1, 2, 3, 4, 5).

Scikit-learn is built on top of numpy, which in turn uses libraries such as OpenBLAS or Atlas to perform calculations as efficiently as possible on the specific hardware in your computer.

However, the default versions compiled for Debian and Ubuntu target older CPUs, on the basis that future processors would be able to execute code for older processors, but this isn't generally true the other way round.

In this case however, newer AMD CPUs have had the instructions removed, and so you receive an Illegal instruction error, despite having valid python code, since the underlying libraries are trying to use the older instructions that are no longer present.

If this is what is happening, then the fix is to build numpy and OpenBLAS for the actual processor in your laptop, instead of the generic one shipped by Debian. Though this example is for Ubuntu, the instructions given by https://hunseblog.wordpress.com/2014/09/15/installing-numpy-and-openblas/ should work just fine for Debian.

like image 88
Rich L Avatar answered Oct 14 '22 06:10

Rich L