Why does scikit-learn cause core dumped?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 02:17:08

问题


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.


回答1:


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.




回答2:


You need to uninstall it, manually delete the folder because uninstall does not clean up properly. In my case, I uninstalled scikit-learn-0.17.1 and installed scikit-learn-0.18.1

pip uninstall scikit-learn
rm -rf ~/venv/lib/python2.7/site-packages/sklearn/
pip uninstall scikit-learn



回答3:


This is the list of all the dependency of "python-scikits-learn" package:

  • python-scikits.statsmodels
  • python-skimage
  • python-skimage-doc
  • python-skimage-lib
  • python-sklearn
  • python-sklearn-doc
  • python-sklearn-lib

If all dependencies are met and still your program doesn't work, you should uninstall those binaries and install from the source, a manual installation will detect the correct settings for your system.

You may also try to reinstall package:

sudo apt-get autoremove python-scikits-learn
sudo apt-get install python-scikits-learn

Best regards



来源:https://stackoverflow.com/questions/30440426/why-does-scikit-learn-cause-core-dumped

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!