Home > Software design >  How to initiate cores in parallel package of R
How to initiate cores in parallel package of R

Time:06-29

To initiate the cluster, it is advised to use below codes

library(parallel)
cl <- makeCluster(getOption("cl.cores", 2))

However I fail to understand what is the meaning of getOption("cl.cores", 2)? How exactly I can find the number of cores in my windows system to run parallel computation?

CodePudding user response:

The usual way to do this is:

num_cores  <- parallel::detectCores() # 8 in my case
cluster  <- parallel::makeCluster(num_cores-1)
  • Related