Skip to content
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

feat: set blas threads to 1 #1133

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions R/worker.R
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@ workhorse = function(iteration, task, learner, resampling, param_values = NULL,
old_blas_threads = RhpcBLASctl::blas_get_num_procs()
on.exit(RhpcBLASctl::blas_set_num_threads(old_blas_threads), add = TRUE)
RhpcBLASctl::blas_set_num_threads(1)
} else { # try the bare minimum to disable threading of the most popular blas implementations
old_blas = Sys.getenv("OPENBLAS_NUM_THREADS")
old_mkl = Sys.getenv("MKL_NUM_THREADS")
Sys.setenv(OPENBLAS_NUM_THREADS = 1)
Sys.setenv(MKL_NUM_THREADS = 1)

on.exit({
Sys.setenv(OPENBLAS_NUM_THREADS = old_blas)
Sys.setenv(MKL_NUM_THREADS = old_mkl)
}, add = TRUE)
}
}
# restore logger thresholds
Expand Down
2 changes: 2 additions & 0 deletions man-roxygen/section_parallelization.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
#' One job is one resampling iteration, and all jobs are send to an apply function
#' from \CRANpkg{future.apply} in a single batch.
#' To select a parallel backend, use [future::plan()].
#' More on parallelization can be found in the book:
#' \url{https://mlr3book.mlr-org.com/chapters/chapter10/advanced_technical_aspects_of_mlr3.html}
2 changes: 1 addition & 1 deletion man/Learner.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/benchmark.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/resample.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.