简体   繁体   English

在集群中运行作业时强制加载R软件包

[英]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. 当我以交互模式在HPC群集中运行作业时,可以加载软件包,如果加载失败(不确定为什么某些软件包一开始无法加载),可以通过运行多个library (failed package)来加载它次,但是当我执行qsub my_rscript_job.pbs ,程序包无法加载。

my my_rscript_job.pbs script is: 我的my_rscript_job.pbs脚本是:

#!/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 我需要在map.r脚本中加载的软件包是

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: 如果以交互方式提交作业并将rscript直接提交到终端,可以加载该文件,但是当我执行qsub时,出现以下错误:

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? 有没有办法在将r作为qsub运行时强制加载软件包?

It looks like the version of R on the submit node and the worker node are different. 看起来提交节点和工作节点上的R版本不同。 Run the command R --version and submit a pbs script that only runs R --version . 运行命令R --version并提交仅运行R --version的pbs脚本。 Likely they will be different. 他们可能会有所不同。

The rest of the answer is dependent on your HPC cluster setup. 其余的答案取决于您的HPC群集设置。 Maybe they use modules, in which case you will need to run a command similar to module load R/3.2 . 也许他们使用模块,在这种情况下,您将需要运行类似于module load R/3.2的命令。 Either way, it looks like you need to ask your HPC cluster admins for help. 无论哪种方式,看来您都需要向HPC群集管理员寻求帮助。

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. 运行qsub选项时,有5秒的计时器强制加载程序包。

 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)

    }

I think I also have a similiar situation as the one you are talking @Derek. 我想我和@Derek说话时的情况也很相似。

I had R version 3.0.2 on my machine (Ubuntu 14.04) and worked nicely with the connection with Rapache. 我的机器(Ubuntu 14.04)上安装了R版本3.0.2,并且可以很好地与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. 我将R软件更新到版本3.3.0,并且在机器中,当我将软件包与功能配合使用时,它可以很好地运行。 But on the Rapache it gives me this error. 但是在Rapache上却给了我这个错误。

    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和R上运行R.version,这给了我两个版本! Rapache is running in 3.0.2 and my R on the machine 3.3.0. Rapache在3.0.2中运行,而我的R在3.3.0机器上运行。

I am interessed and knowing more about where can i access this submit node and worker node you are talking. 我受到了关注,并且知道我可以在哪里访问您正在谈论的此提交节点和工作节点的更多信息。

Regards! 问候!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM