Unverified Commit 1548b42b authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] [c++] add tighter multithreading control, avoid global OpenMP side...

[R-package] [c++] add tighter multithreading control, avoid global OpenMP side effects (fixes #4705, fixes #5102) (#6226)
parent e7979852
...@@ -65,6 +65,8 @@ Construct \code{lgb.Dataset} object from dense matrix, sparse matrix ...@@ -65,6 +65,8 @@ Construct \code{lgb.Dataset} object from dense matrix, sparse matrix
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -17,6 +17,8 @@ Construct Dataset explicitly ...@@ -17,6 +17,8 @@ Construct Dataset explicitly
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -48,6 +48,8 @@ Construct validation data according to training data ...@@ -48,6 +48,8 @@ Construct validation data according to training data
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -20,6 +20,8 @@ Please note that \code{init_score} is not saved in binary file. ...@@ -20,6 +20,8 @@ Please note that \code{init_score} is not saved in binary file.
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -22,6 +22,8 @@ Set the categorical features of an \code{lgb.Dataset} object. Use this function ...@@ -22,6 +22,8 @@ Set the categorical features of an \code{lgb.Dataset} object. Use this function
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -19,6 +19,8 @@ If you want to use validation data, you should set reference to training data ...@@ -19,6 +19,8 @@ If you want to use validation data, you should set reference to training data
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
# create training Dataset # create training Dataset
data(agaricus.train, package ="lightgbm") data(agaricus.train, package ="lightgbm")
train <- agaricus.train train <- agaricus.train
......
...@@ -114,6 +114,8 @@ Calling this function multiple times with different parameters might not overrid ...@@ -114,6 +114,8 @@ Calling this function multiple times with different parameters might not overrid
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
library(lightgbm) library(lightgbm)
data(mtcars) data(mtcars)
X <- as.matrix(mtcars[, -1L]) X <- as.matrix(mtcars[, -1L])
......
...@@ -152,6 +152,8 @@ Cross validation logic used by LightGBM ...@@ -152,6 +152,8 @@ Cross validation logic used by LightGBM
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -20,6 +20,8 @@ Dump LightGBM model to json ...@@ -20,6 +20,8 @@ Dump LightGBM model to json
\examples{ \examples{
\donttest{ \donttest{
library(lightgbm) library(lightgbm)
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -33,6 +33,8 @@ Given a \code{lgb.Booster}, return evaluation results for a ...@@ -33,6 +33,8 @@ Given a \code{lgb.Booster}, return evaluation results for a
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
# train a regression model # train a regression model
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
......
...@@ -25,6 +25,8 @@ Creates a \code{data.table} of feature importances in a model. ...@@ -25,6 +25,8 @@ Creates a \code{data.table} of feature importances in a model.
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -30,6 +30,8 @@ Computes feature contribution components of rawscore prediction. ...@@ -30,6 +30,8 @@ Computes feature contribution components of rawscore prediction.
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
Logit <- function(x) log(x / (1.0 - x)) Logit <- function(x) log(x / (1.0 - x))
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
......
...@@ -20,6 +20,8 @@ Load LightGBM takes in either a file path or model string. ...@@ -20,6 +20,8 @@ Load LightGBM takes in either a file path or model string.
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -40,6 +40,8 @@ Parse a LightGBM model json dump into a \code{data.table} structure. ...@@ -40,6 +40,8 @@ Parse a LightGBM model json dump into a \code{data.table} structure.
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -38,6 +38,8 @@ Features are shown ranked in a decreasing importance order. ...@@ -38,6 +38,8 @@ Features are shown ranked in a decreasing importance order.
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -35,6 +35,8 @@ contribution of a feature. Features are shown ranked in a decreasing contributio ...@@ -35,6 +35,8 @@ contribution of a feature. Features are shown ranked in a decreasing contributio
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
Logit <- function(x) { Logit <- function(x) {
log(x / (1.0 - x)) log(x / (1.0 - x))
} }
......
...@@ -27,7 +27,10 @@ function. If you wish to make fast single-row predictions using a \code{lgb.Boos ...@@ -27,7 +27,10 @@ function. If you wish to make fast single-row predictions using a \code{lgb.Boos
call \link{lgb.configure_fast_predict} on the loaded \code{lgb.Booster} object. call \link{lgb.configure_fast_predict} on the loaded \code{lgb.Booster} object.
} }
\examples{ \examples{
\donttest{
library(lightgbm) library(lightgbm)
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data("agaricus.train") data("agaricus.train")
model <- lightgbm( model <- lightgbm(
agaricus.train$data agaricus.train$data
...@@ -45,6 +48,7 @@ model_new$check_null_handle() ...@@ -45,6 +48,7 @@ model_new$check_null_handle()
lgb.restore_handle(model_new) lgb.restore_handle(model_new)
model_new$check_null_handle() model_new$check_null_handle()
} }
}
\seealso{ \seealso{
\link{lgb.make_serializable}, \link{lgb.drop_serialized}. \link{lgb.make_serializable}, \link{lgb.drop_serialized}.
} }
...@@ -21,6 +21,8 @@ Save LightGBM model ...@@ -21,6 +21,8 @@ Save LightGBM model
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
library(lightgbm) library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
......
...@@ -130,6 +130,8 @@ Low-level R interface to train a LightGBM model. Unlike \code{\link{lightgbm}}, ...@@ -130,6 +130,8 @@ Low-level R interface to train a LightGBM model. Unlike \code{\link{lightgbm}},
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -121,6 +121,8 @@ If the model object has been configured for fast single-row predictions through ...@@ -121,6 +121,8 @@ If the model object has been configured for fast single-row predictions through
} }
\examples{ \examples{
\donttest{ \donttest{
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment