Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python macOS High Sierra上的XGBoost并行化问题_Python_Macos_Openmp_Xgboost_Macos High Sierra - Fatal编程技术网

Python macOS High Sierra上的XGBoost并行化问题

Python macOS High Sierra上的XGBoost并行化问题,python,macos,openmp,xgboost,macos-high-sierra,Python,Macos,Openmp,Xgboost,Macos High Sierra,我在macOS High Sierra上使用Anaconda环境,无法使用8线程运行XGBoost,即使我将nthread参数设置为8 python代码如下所示。当我运行它时,我通过查看htop来监视执行。只有一种工艺是100% clf = xgb.XGBClassifier( **xgb_params, n_estimators=1000, nthread=8 ) 然后我在网上搜索,找到了这个链接。有些人提到这一点,我也照做了 看到这些信息后,我在xgboos

我在macOS High Sierra上使用Anaconda环境,无法使用8线程运行XGBoost,即使我将nthread参数设置为8

python代码如下所示。当我运行它时,我通过查看htop来监视执行。只有一种工艺是100%

clf = xgb.XGBClassifier(
     **xgb_params,
     n_estimators=1000,
     nthread=8
)
然后我在网上搜索,找到了这个链接。有些人提到这一点,我也照做了

看到这些信息后,我在xgboost配置中添加了以下几行

export CC = gcc-8
export CXX = g++-8
当构建完成时。我又试了一次,什么也没变

所以,我一直在寻找解决方案。我找到了这一页

然后我跑了下面一行

brew install llvm
我试着在那个网站上做这个例子。我创建了一个名为hello.c的文件,并将以下代码放入其中

#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
  printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), 
  omp_get_num_threads());
}
成功了!我还尝试了gcc-8,如下所示

gcc-8 -fopenmp hello.c -o hello
它也起了作用。这是我运行时的输出。/hello

所以,我在xgboost配置文件中添加了gcc-8,您可以看到,gcc-8能够与-fopenmp选项并行运行。但是,XGBoost不会并行运行,即使我使用此设置编译它并将nthread参数设置为8

有没有办法让我再试试

编辑1:我尝试了更复杂的代码,以确保并行化工作正常。我试过了。输出显示8个线程的工作。我还通过键入htop来查看它

编辑2:我安装了gcc-7并执行了相同的过程。它也不起作用

clang -fopenmp hello.c -o hello
gcc-8 -fopenmp hello.c -o hello
➜  ~ ./hello 
Hello from thread 4, nthreads 8
Hello from thread 7, nthreads 8
Hello from thread 2, nthreads 8
Hello from thread 1, nthreads 8
Hello from thread 6, nthreads 8
Hello from thread 3, nthreads 8
Hello from thread 0, nthreads 8
Hello from thread 5, nthreads 8
➜  ~ clang -fopenmp OpenMP.c -o OpenMP
➜  ~ ./OpenMP 
---- Serial
---- Serial done in 37.058571 seconds.
---- Parallel
---- Parallel done in 9.674641 seconds.
---- Check
Passed