Skip to content

Commit

Permalink
feat: reduce blas threads to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed Dec 13, 2023
1 parent f465cf5 commit 8cd42ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Imports:
parallelly,
palmerpenguins,
paradox (>= 0.10.0),
RhpcBLASctl,
uuid
Suggests:
Matrix,
Expand Down
9 changes: 7 additions & 2 deletions R/worker.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,13 @@ workhorse = function(iteration, task, learner, resampling, param_values = NULL,
pb(sprintf("%s|%s|i:%i", task$id, learner$id, iteration))
}

# reduce data.table threads to 1
if (!is_sequential) setDTthreads(1)
# reduce data.table and blas threads to 1
if (!is_sequential) {
setDTthreads(1, restore_after_fork = TRUE)
old_blas_threads = blas_get_num_procs()
on.exit(blas_set_num_threads(old_blas_threads), add = TRUE)
blas_set_num_threads(1)
}

# restore logger thresholds
for (package in names(lgr_threshold)) {
Expand Down
1 change: 1 addition & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' @importFrom uuid UUIDgenerate
#' @importFrom parallelly availableCores
#' @importFrom future nbrOfWorkers plan
#' @importFrom RhpcBLASctl blas_set_num_threads
#'
#' @section Learn mlr3:
#' * Book on mlr3: \url{https://mlr3book.mlr-org.com}
Expand Down

0 comments on commit 8cd42ca

Please sign in to comment.