为什么 scikit-learn 会导致核心转储? [英] Why does scikit-learn cause core dumped?

查看:66
本文介绍了为什么 scikit-learn 会导致核心转储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 scikit-learn 中运行一个简单的线性拟合:

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])

结果我得到:

Illegal instruction (core dumped)

有谁知道这个问题的原因是什么以及如何解决这个问题?

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

附言我使用 scikit-learn 的 0.16.1 版本.但是我在旧版本中也遇到了这个问题.我是在 Ubuntu 下做的.

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.

添加

今天我尝试了另一个估算器(KernelRidge),但得到了同样的错误信息.我认为几个月前我尝试使用 scipy 求解线性方程组,但我遇到了同样的错误.我需要补充一点,我尝试过的例子总是很小(所以,问题的大小不应该是错误的原因).在其他计算机上(在工作中)我也有 Ubunutu 并使用 scikit-learn,我没有他们的这个问题.所以,我的家用笔记本电脑好像出了点问题.

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.

推荐答案

在这里尝试一下,但您的笔记本电脑是否有机会配备 AMD CPU?

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

AMD 已取消对 3DNow! 的支持!来自他们最新处理器的说明(来源),对 Ubuntu 和 Debian 错误跟踪器的搜索显示,很多人都受到了攻击(例如 1234, 5).

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 建立在 numpy 之上,后者又使用 OpenBLAS 或 Atlas 等库在您计算机的特定硬件上尽可能高效地执行计算.

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.

然而,为 Debian 和 Ubuntu 编译的默认版本针对的是较旧的 CPU,因为未来的处理器将能够为较旧的处理器执行代码,但反过来说通常情况并非如此.

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.

然而,在这种情况下,较新的 AMD CPU 已经删除了指令,因此尽管具有有效的 Python 代码,您仍会收到 Illegal instructions 错误,因为底层库正在尝试使用较旧的指令不再存在.

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.

如果发生这种情况,那么解决方法是为笔记本电脑中的实际处理器构建 numpy 和 OpenBLAS,而不是 Debian 提供的通用处理器.尽管此示例适用于 Ubuntu,但 https://hunseblog.wordpress.com/2014/09/15/installing-numpy-and-openblas/ 应该适用于 Debian.

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.

这篇关于为什么 scikit-learn 会导致核心转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆