matteo
matteo

Reputation: 311

Stan code works fine but fails on Linux cluster

I have a stan model which run perfectly fine on my own laptop (Ubuntu 16.04) but fails when run on the cluster (Centos 7.3).

Here is the error message I receive:

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

I don't understand where the problem is, since the same exact script runs OK on my laptop. Any suggestions?

Upvotes: 1

Views: 819

Answers (1)

matteo
matteo

Reputation: 311

As suggested in the comments, the problem was in the compilation flags used to install RStan. In my case the issue was solved by reinstalling RStan and Rcpp in a separate library folder, and using the correct compilation flags. Specifically, the content of the ~/.R/Makevars file in my case was set to

CXX14 = g++ -std=c++1y
CXX14FLAGS = -O3 -Wno-unused-variable -Wno-unused-function -fPIC

Upvotes: 2

Related Questions