我有一个stan模型,可以在我自己的笔记本电脑(Ubuntu 16.04)上很好地运行,但是在群集上(Centos 7.3)运行时失败。在群集上安装Stan似乎工作正常(8schools.stan
示例运行没有问题)。
这是我收到的错误消息:
Loading R/3.5.3
Loading requirement: java/1.8.0_171-oracle
Loading required package: ggplot2
Loading required package: StanHeaders
*** caught illegal operation ***
address 0x2b87c71f0061, cause 'illegal operand'
Traceback:
1: get_rng(0)
2: assign(x, value, envir = ns, inherits = FALSE)
3: assignInMyNamespace("RNG", value = get_rng(0))
4: fun(libname, pkgname)
5: doTryCatch(return(expr), name, parentenv, handler)
6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
7: tryCatchList(expr, classes, parentenv, handlers)
8: tryCatch(fun(libname, pkgname), error = identity)
9: runHook(".onLoad", env, package.lib, package)
10: loadNamespace(package, lib.loc)
11: doTryCatch(return(expr), name, parentenv, handler)
12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
13: tryCatchList(expr, classes, parentenv, handlers)
14: tryCatch({ attr(package, "LibPath") <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) { P <- if (!is.null(cc <- conditionCall(e))) paste(" in", deparse(cc)[1L]) else "" msg <- gettextf("package or namespace load failed for %s%s:\n %s", sQuote(package), P, conditionMessage(e)) if (logical.return) message(paste("Error:", msg), domain = NA) else stop(msg, call. = FALSE, domain = NA)})
15: library(rstan)
An irrecoverable exception occurred. R is aborting now ...
/opt/sge_spool/8.5.4/dn110/job_scripts/695494: line 9: 31202 Illegal instruction Rscript MLDS_stan_v3.R
我不明白问题出在哪里,因为相同的脚本可以在笔记本电脑上正常运行。有什么建议吗?
答案 0 :(得分:1)
如评论中所建议,问题出在用于安装RStan的编译标志中。在我的情况下,可以通过在单独的库文件夹中重新安装RStan和Rcpp并使用正确的编译标志来解决此问题。具体来说,在我的案例中,~/.R/Makevars
文件的内容设置为
CXX14 = g++ -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function -fPIC