-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[R] Don't cap global number of threads #10028
Conversation
Regarding the failing CI job:
Looks like the vignette builder is not installing all the packages mentioned under |
Please help update the CI script: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks good; I like the small utility library. Please see the comments around the documentation.
R-package/R/xgb.config.R
Outdated
#' controlling the number of parallel threads that will be used, but some functionalities | ||
#' might execute functions before this parameter can be supplied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only feature that has problems with local nthread
is the model serialization, let's be more specific here to reduce confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
R-package/R/xgb.config.R
Outdated
#' In such cases, the global number of threads is taken from the configured number of OpenMP | ||
#' (OMP) threads, which if not set, will default to the maximum number of available threads. | ||
#' The number of OMP threads in turn can be configured through an environment variable | ||
#' `OMP_NUM_THREADS` (which needs to be set before R is started), or alternatively, can be | ||
#' changed in an R session through package `RhpcBLASctl`, by calling function `RhpcBLASctl::omp_set_num_threads`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a simple note that in addition to the nthread
parameter, XGBoost honors global configuration set by OMP_NUM_THREADS
or RhpcBLASctl
should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified.
R tests are now passing. |
ref #9810
ref #10027
This PR removes manual capping of number of threads in XGBoost functions that take it from a global config instead of being supplied as argument.
CRAN has a requirement of not using more than 2 threads in tests and examples, so it substitutes this workaround with a manual setting of OMP threads config, which is done through a new dependency
RhpcBLASctl
that provides such functionality; and adds silent calls to it before the tests that might execute something with the global number of OMP threads, the same way it was done in LightGBM: microsoft/LightGBM#6226Note: I am not entirely sure that I added silent calls to this function that sets the OMP threads in all of the examples where it's needed.