Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
Example:
module load R/4.0.3

> library(plyr)

> library(doParallel)

Loading required package: foreach

Loading required package: iterators

Loading required package: parallel
>cores > cores <- detectCores()

> cores>cores

[1] 72

> registerDoParallel(cores=12)

> fake_func <- function(x) {

+ 
 Sys.sleep(0.1)

+
  return(x)

+ }

>
 
> library(microbenchmark)

> microbenchmark(

+   serial = llply(1:24, fake_func),

+  
parallel = llply(1:24, fake_func, .parallel = TRUE),

+
  times = 1

+ )

Unit: milliseconds

     expr       min        lq      mean    median        uq       max neval

   serial 2424.3580 2424.3580 2424.3580 2424.3580 2424.3580 2424.3580     1

 parallel  226.2199  226.2199  226.2199  226.2199  226.2199  226.2199     1

> 


Sample interactive pbs run


No Format
qsub -I -l select=1:ncpus=8:mem=12gb,walltime=1:11:00 -q small
Once you are on the compute node:
module load R/4.0.3
R
library(plyr)
library(doParallel)
cores <- detectCores()
cores
[1] 12
registerDoParallel(cores=8)
fake_func <- function(x) {
Sys.sleep(0.1)
return(x)
}
library(microbenchmark)
microbenchmark(
serial = llply(1:24, fake_func),
parallel = llply(1:24, fake_func, .parallel = TRUE),
times = 1
)


Unit: milliseconds
     expr       min        lq      mean    median        uq       max neval
   serial 2402.7702 2402.7702 2402.7702 2402.7702 2402.7702 2402.7702     1
 parallel  320.0491  320.0491  320.0491  320.0491  320.0491  320.0491     1
> 


Reference

1. http://yusung.blogspot.com.au/2009/01/install-jags-and-rjags-in-fedora.html

...