Build RStan

From HPC

Jump to: navigation, search

Build RStan as a qsub job

Notes

  • RStan requires a newer version of GCC so that must be loaded as a module.
  • You can change the module load line for R to which ever version you prefer.
  • Once job finishes you can look a build.out to check for completion.
  • The build.R will modify the R Makevars file to add CXX14FLAGS and CXX14


QSUB script

#!/bin/bash
#$ -N R_BUILD_JOB
#$ -M email@lshtm.ac.uk -m be
#$ -q short.q
#$ -l mem_free=4G,h_vmem=4.2G
#$ -V -cwd

module load gcc/6.5.0
module load R/3.5.3

which R
which gcc

R CMD BATCH build.R build.out


build.R

dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O2 -march=native -mtune=native -fPIC",
   "CXX14=g++", # or clang++ but you may need a version postfix
   file = M, sep = "\n", append = TRUE)

install.packages("rstan", type = "source", repos = "https://cloud.r-project.org/", dependencies = TRUE)
Personal tools