问题描述
如果我只是运行 R 代码,那么它就可以工作。但是,当我提交作业时它不起作用。
我正在尝试通过提交作业来运行 myRcode.R
文件。以下是 .sh
文件:
#!/bin/bash
#PBS -N myRexample # Set job name to myjob
#PBS -l nodes=1:ppn=2 # Request 1 node with 2 processors
#PBS -l mem=8gb # Request 8gb memory
#PBS -l walltime=1:00:00 # Request 1hr job time
#PBS -V # Use submission environment
cd "$PBS_O_WORKDIR"
Rscript myRcode.R
以下是我的 R 代码 (myRcode.R
):
#!/usr/bin/env Rscript
#Call the required functions and library
source("function1.R")
library(R2jags)
#Function to be used in parallel computation
mysim <- function(sim_number){
set.seed(sim_number)
outs <- function1() #rjags is called inside function1.
return(list(outs[[1]],outs[[2]]))
}
#Parallel Computation
library(parallel)
library(doParallel)
registerDoParallel(cl <- parallel::makeCluster(2,outfile="test.txt"));
results <- foreach(x = 1:2,.packages = c('MASS','R2jags'))%dopar% { mysim(sim_number=x)}
stopCluster(cl)
以下是我得到的错误:
Loading required package: rjags
Loading required package: coda
Linked to JAGS 4.0.0
Loaded modules: basemod,bugs
Attaching package: ‘R2jags’
The following object is masked from ‘package:coda’:
traceplot
Loading required package: foreach
Loading required package: iterators
Error in unserialize(socklist[[n]]) : error reading from connection
Calls: %dopar% ... recvOneData -> recvOneData.SOCKcluster -> unserialize
Execution halted
以下是 test.txt
文件:
starting worker pid=59438 on localhost:11788 at 08:55:04.422
starting worker pid=59451 on localhost:11788 at 08:55:04.799
Loading required package: rjags
Loading required package: rjags
Loading required package: coda
Loading required package: coda
Linked to JAGS 4.0.0
Loaded modules: basemod,bugs
Linked to JAGS 4.0.0
Loaded modules: basemod,bugs
Attaching package: ‘R2jags’
Attaching package: ‘R2jags’
The following object is masked from ‘package:coda’:
traceplot
The following object is masked from ‘package:coda’:
traceplot
*** caught illegal operation ***
address 0x7f51ceed1917,cause 'illegal operand'
*** caught illegal operation ***
address 0x7fe45c73d917,cause 'illegal operand'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)