(disclaim: I'm the author) To minimize the risk of overusing CPUs on multi-tenant and multi-process machines, but also to work in more environments, please consider changing:
|
get_cores <-function(num_cores){ |
|
|
|
if(is.null(num_cores)) { |
|
parallel::detectCores()-1 |
|
} else { |
|
min(num_cores, parallel::detectCores()-1) |
|
} |
|
} |
to
get_cores <-function(num_cores){
min(c(parallelly::availableCores(omit = 1), num_cores))
}
This also has the benefit of working on single-core hosts, where detectCores() == 1, e.g. free RStudio Cloud accounts, some k8s/container setups, etc. For more arguments, see https://parallelly.futureverse.org/#availablecores-vs-paralleldetectcores.
(disclaim: I'm the author) To minimize the risk of overusing CPUs on multi-tenant and multi-process machines, but also to work in more environments, please consider changing:
finnts/R/general_parallel.R
Lines 6 to 13 in 57207bf
to
This also has the benefit of working on single-core hosts, where
detectCores() == 1, e.g. free RStudio Cloud accounts, some k8s/container setups, etc. For more arguments, see https://parallelly.futureverse.org/#availablecores-vs-paralleldetectcores.