Achal Neupane
Achal Neupane

Reputation: 5719

Force load R packages while running the job in cluster

When I run a job in HPC cluster in interactive mode, I can load the packages and if it fails (not sure why some packages fail to load at first instance) to load, I can load it by running the library (failed package) multiple times, but when I do qsub my_rscript_job.pbs, the packages fail to load.

my my_rscript_job.pbs script is:

#!/bin/bash 
#PBS -l walltime=100:00:00
#PBS -l ncpus=1,mem=100g

source ~/.bashrc

Rscript /dmf/mypath/map.r -t 100

The packages I need to load in the map.r script are

library(biomaRt)
library(dplyr)
library(stringi)
library(GenomicFeatures)
library(Rsamtools)
library(foreach)
library(doMC)
library(doMC)

which I can load if I submit the job in interactive mode and submit the rscript directly to the terminal, but when I do qsub I get the following error:

Loading required package: methods
Warning messages:
1: package ‘biomaRt’ was built under R version 3.2.2 
2: In eval(quote({ : bytecode version mismatch; using eval
3: In .recacheSubclasses(def@className, def, doSubclasses, env) :
  undefined subclass "externalRefMethod" of class "expressionORfunction"; definition not updated
4: In .recacheSubclasses(def@className, def, doSubclasses, env) :
  undefined subclass "externalRefMethod" of class "functionORNULL"; definition not updated
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/dmf/bin/R/x86_64-redhat-linux-gnu-library/3.2/dplyr/libs/dplyr.so':
  /dmf/bin/R/x86_64-redhat-linux-gnu-library/3.2/dplyr/libs/dplyr.so: undefined symbol: Rf_installChar
In addition: Warning message:
package ‘dplyr’ was built under R version 3.2.2 
Error: package or namespace load failed for ‘dplyr’
Execution halted

Is there a way to force load the packages while running r as qsub?

Upvotes: 0

Views: 1439

Answers (3)

Achal Neupane
Achal Neupane

Reputation: 5719

Setting timer to reload each package until each package in the list is successfully loaded. There is a timer of 5 second to force load the package when running the qsub option.

 myPackages <- c("biomaRt", "dplyr", "stringi","GenomicFeatures","Rsamtools","foreach","doMC")
    tryCount <- 0    

    while( !all(myPackages %in% (.packages())) ){

      try(require(biomaRt))
      try(require(dplyr))
      try(require(stringi))
      try(require(GenomicFeatures))
      try(require(Rsamtools))
      try(require(foreach))
      try(require(doMC))

      tryCount <- tryCount + 1

      if( !all(myPackages %in% (.packages()))  ){
        cat(paste0("Failure: ", tryCount, "\n"))
        cat("Failed to load: ")
        cat(myPackages[ !myPackages %in% (.packages()) ])
        cat("\n")
      } else {
        print(paste0("Success!"))
      }

      Sys.sleep(5)

    }

Upvotes: 1

Toni_Mashengo
Toni_Mashengo

Reputation: 11

I think I also have a similiar situation as the one you are talking @Derek.

I had R version 3.0.2 on my machine (Ubuntu 14.04) and worked nicely with the connection with Rapache. I updated the R software to version 3.3.0, and in the machine it runs nicely when i use packages with my functions. But on the Rapache it gives me this error.

    Error in dyn.load(file, DLLpath = DLLpath, ...) :
    unable to load shared object '/usr/lib/R/library/grid/libs/grid.so':
    /usr/lib/R/library/grid/libs/grid.so: undefined symbol: Rf_installChar

I run R.version on Rapache and R, and it gave me different versions for both! Rapache is running in 3.0.2 and my R on the machine 3.3.0.

I am interessed and knowing more about where can i access this submit node and worker node you are talking.

Regards!

Upvotes: 0

Derek
Derek

Reputation: 801

It looks like the version of R on the submit node and the worker node are different. Run the command R --version and submit a pbs script that only runs R --version. Likely they will be different.

The rest of the answer is dependent on your HPC cluster setup. Maybe they use modules, in which case you will need to run a command similar to module load R/3.2. Either way, it looks like you need to ask your HPC cluster admins for help.

Upvotes: 3

Related Questions