setting "nthread" does not work for R xgboost?
Hi, I am using xgboost R package to do some optimizaton, and in order to speed computation, I tried multi-thread. The problem is after I set "nthread", it seems no speed improvement. Does any one have idea how I should configure? My environment is Ubuntu + R. Thanks a lot!
Please fill the issue template when opening a new one (detailed ). Including the required information makes the problem solving process faster.
Specifically, please include
If you are using R package, please provide
1. The R `sessionInfo()`
2. The command to install `xgboost` if you are not installing from source
## Steps to reproduce
1.
2.
3.
## What have you tried?
1.
2.
3.
thank you very much! If you are using R package, please provide
- The R
sessionInfo()sessionInfo() R version 3.2.5 (2016-04-14) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.2 LTS
locale:
[1] LC_CTYPE=zh_CN.UTF-8 LC_NUMERIC=C
[3] LC_TIME=zh_CN.UTF-8 LC_COLLATE=zh_CN.UTF-8
[5] LC_MONETARY=zh_CN.UTF-8 LC_MESSAGES=zh_CN.UTF-8
[7] LC_PAPER=zh_CN.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices utils datasets methods base
- The command to install
xgboostif you are not installing from source I install xgboost using
R> install.packages('xgboost')
Steps to reproduce
-
The code is a bit to large, I actually I called the xgboost train function like this:
model <- xgb.train(params = params, data = dtrain, obj = Gradfun, feval = Lossfun, nrounds, watchlist = watchlist, early.stop.round = early.stop.round, maximize = F, verbose = verbose, print.every.n = print.every.n)
the 'nthread' parameter is set in 'params'
What have you tried?
- I just found the consumed time after I set nthread to 1 and to 4 are almost the same
do not know how to check whether I am in the right track.
thanks a lot!
there is difference of time consuming after I setting different nthread value , although it is not such significant enhancement , it seems works. Do you have any idea how to further improve the speed?
My machine has 24 cpus, and after a rough test, when setting nthread = 8 , gives a little better result, while setting nthread = 16 or 24 is even worse than single thread.
- What is the size of your data, i.e. rows and columns?
- What is the change of the CPU rate when you change the
nthreadsetting?
- the size of data is like: rows = 300k , columns = 1000
- when nthread goes from 1 to 8, the total time spent reduced by 50%, while nthread goes further to 16 and 24, the total time much longer.
i've tried various input datasets, with various hyperparameter tunings, on a large machine (128 cores) and have seen similar behavior (after ~16 threads, performance gets worse)