XGBoost 不使用 Windows 下可用的最大内核数? [英] XGBoost not using max number of cores available under Windows?

查看:68
本文介绍了XGBoost 不使用 Windows 下可用的最大内核数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 R 包使用 XGBoost,并且没有指定 nthread 参数(应该默认为可用内核的最大数量,它在 Ubuntu 中是这样的).

I am using XGBoost via the R package, and did not specify an nthread parameter (should default to the maximum number of available cores, which it does in Ubuntu).

在配备 i7-4770 CPU(具有 4 个内核 = 8 个线程)的 Windows PC 上,但是,最多只有达到最大 CPU 级别的 50%,即使我手动设置 nthread = 8 (完全相同的代码在 Ubuntu 下使用 100% 的最大 CPU 级别,所以我认为这不是实现问题).我还尝试了 nthread = 4 这导致大约 30% 的最大 CPU 使用率.

On a Windows PC with an i7-4770 CPU (which has 4 cores = 8 threads), however, only max. 50% of the max CPU level is reached, even when I manually set nthread = 8 (The exact same code uses 100% of max CPU level under Ubuntu, so this is not an implementation issue I think). I also tried nthread = 4 which leads to around 30% of max CPU usage.

如何让 XGBoost 使用 Windows 下的所有可用线程?

How do I get XGBoost to use all available threads under Windows?

推荐答案

我发现当通过 install.packages("xgboost") 从 CRAN 安装 Windows XGBoost R 包时,它确实没有 MPI 支持.如果没有 MPI,您将无法获得并行处理的全部好处,并且您的 CPU 将无法得到充分利用.您可以通过在 xgboost.dll 文件上使用 Dependency Walker 之类的软件在您的场景中确认这一点 - 您会注意到它不与任何 MPI 库(通常是 vcomp140.dllem> 在 Windows 上).

I've found that when installing the Windows XGBoost R package from CRAN via install.packages("xgboost") it does not have MPI support. Without MPI you will not get the full benefit of parallel processing and your CPUs will be under-utilised. You can confirm this in your scenario by using software like Dependency Walker on the xgboost.dll file—you will note that it doesn't link with any MPI library (usually vcomp140.dll on Windows).

就我而言,解决方案是卸载 CRAN 提供的 R 包并从源代码构建 XGBoost 及其 R 包,这本身就是一次冒险,但确实给了我一个支持 MPI 的安装,将所有 16 个内核推送到我的系统达到 100% 的利用率.

The solution in my case was to uninstall the CRAN-supplied R package and build XGBoost and its R package from source, which was an adventure in itself, but did give me an MPI-enabled installation that pushed all 16 cores in my system to 100% utilisation.

(为了更清晰而编辑)

这篇关于XGBoost 不使用 Windows 下可用的最大内核数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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