I am trying to run a very simple model with rstan in batch mode. When I try to run the same code, but not in batch mode, I do not have this error.
I checked a similar discussion (Error when running rstan with linux) in the forum, but my knownledge in Linux is limited. My R code and error message are below.
R code:
### Libraries
library(rstan)
library(foreach)
library(doParallel)
library(doRNG)
### Simulation parameters
ncores <- 28
n_sim <- 1000
registerDoParallel(ncores)
set.seed(1234)
results <- foreach(i = 1:n_sim,
.combine='c',
.packages = "rstan",
.verbose = TRUE) %dorng% {
scode <- "
parameters {
real y[2];
}
model {
y[1] ~ normal(0, 1);
y[2] ~ double_exponential(0, 2);
}
"
fit1 <- stan(model_code = scode, iter = 10, verbose = TRUE)
}
stopImplicitCluster()
Error message:
> ### Libraries
> library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.2, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
> library(foreach)
> library(doParallel)
Loading required package: iterators
Loading required package: parallel
> library(doRNG)
Loading required package: rngtools
>
> ### Simulation parameters
> ncores <- 5
> n_sim <- 5
>
>
>
> registerDoParallel(ncores)
>
> set.seed(1234)
> results <- foreach(i = 1:n_sim,
+ .combine='c',
+ .packages = "rstan",
+ .verbose = TRUE) %dorng% {
+
+ scode <- "
+ parameters {
+ real y[2];
+ }
+ model {
+ y[1] ~ normal(0, 1);
+ y[2] ~ double_exponential(0, 2);
+ }
+ "
+ fit1 <- stan(model_code = scode, iter = 10, verbose = TRUE)
+
+ }
numValues: 5, numResults: 0, stopped: TRUE
# Original RNG: Mersenne-Twister - Inversion - Rejection [10403, 624, -1394370482, -1723143049, 2071488076, 1659356893, -1081051142, ...]
# Generate random RNGstream seed: OK
# Seed RNGkind is: L'Ecuyer-CMRG - Inversion - Rejection [10407, -305383241, 69318028, -1161659107, -348804806, -1127582349, -343284712]
# Restoring RNG: Mersenne-Twister - Inversion - Rejection [10403, 1, 1407173775, 141192598, 911446336, 1689480195, -1101853151, ...]
* Registered backend: doParallelMC
numValues: 5, numResults: 0, stopped: TRUE
TRANSLATING MODEL '459f18aa440866d112562fa03ce604f7' FROM Stan CODE TO C++ CODE NOW.
TRANSLATING MODEL '459f18aa440866d112562fa03ce604f7' FROM Stan CODE TO C++ CODE NOW.
TRANSLATING MODEL '459f18aa440866d112562fa03ce604f7' FROM Stan CODE TO C++ CODE NOW.
TRANSLATING MODEL '459f18aa440866d112562fa03ce604f7' FROM Stan CODE TO C++ CODE NOW.
TRANSLATING MODEL '459f18aa440866d112562fa03ce604f7' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model '459f18aa440866d112562fa03ce604f7'.
successful in parsing the Stan model '459f18aa440866d112562fa03ce604f7'.
successful in parsing the Stan model '459f18aa440866d112562fa03ce604f7'.
successful in parsing the Stan model '459f18aa440866d112562fa03ce604f7'.
successful in parsing the Stan model '459f18aa440866d112562fa03ce604f7'.
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.7; inline: 0.3.19
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.7; inline: 0.3.19
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.7; inline: 0.3.19
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.7; inline: 0.3.19
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.7; inline: 0.3.19
Trying to compile a simple C file
Trying to compile a simple C file
Trying to compile a simple C file
Trying to compile a simple C file
Trying to compile a simple C file
Running /hpc/apps/R/4.1.2/lib64/R/bin/R CMD SHLIB foo.c
Running /hpc/apps/R/4.1.2/lib64/R/bin/R CMD SHLIB foo.c
Running /hpc/apps/R/4.1.2/lib64/R/bin/R CMD SHLIB foo.c
Running /hpc/apps/R/4.1.2/lib64/R/bin/R CMD SHLIB foo.c
Running /hpc/apps/R/4.1.2/lib64/R/bin/R CMD SHLIB foo.c
gcc -I"/hpc/apps/R/4.1.2/lib64/R/include" -DNDEBUG -I/hpc/apps/zlib/1.2.8/include -I/hpc/apps/pcre/8.38/include -I/hpc/apps/bzip2/1.0.6/include -I/hpc/apps/curl/7.54.1/include -I/hpc/apps/cairo/1.14.12/include -fpic -g -O2 -c foo.c -o foo.o
gcc -I"/hpc/apps/R/4.1.2/lib64/R/include" -DNDEBUG -I/hpc/apps/zlib/1.2.8/include -I/hpc/apps/pcre/8.38/include -I/hpc/apps/bzip2/1.0.6/include -I/hpc/apps/curl/7.54.1/include -I/hpc/apps/cairo/1.14.12/include -fpic -g -O2 -c foo.c -o foo.o
gcc -I"/hpc/apps/R/4.1.2/lib64/R/include" -DNDEBUG -I/hpc/apps/zlib/1.2.8/include -I/hpc/apps/pcre/8.38/include -I/hpc/apps/bzip2/1.0.6/include -I/hpc/apps/curl/7.54.1/include -I/hpc/apps/cairo/1.14.12/include -fpic -g -O2 -c foo.c -o foo.o
gcc -I"/hpc/apps/R/4.1.2/lib64/R/include" -DNDEBUG -I/hpc/apps/zlib/1.2.8/include -I/hpc/apps/pcre/8.38/include -I/hpc/apps/bzip2/1.0.6/include -I/hpc/apps/curl/7.54.1/include -I/hpc/apps/cairo/1.14.12/include -fpic -g -O2 -c foo.c -o foo.o
gcc -I"/hpc/apps/R/4.1.2/lib64/R/include" -DNDEBUG -I/hpc/apps/zlib/1.2.8/include -I/hpc/apps/pcre/8.38/include -I/hpc/apps/bzip2/1.0.6/include -I/hpc/apps/curl/7.54.1/include -I/hpc/apps/cairo/1.14.12/include -fpic -g -O2 -c foo.c -o foo.o
gcc -shared -L/hpc/apps/R/4.1.2/lib64/R/lib -L/hpc/apps/zlib/1.2.8/lib -L/hpc/apps/pcre/8.38/lib -L/hpc/apps/bzip2/1.0.6/lib -L/hpc/apps/curl/7.54.1/lib -L/hpc/apps/cairo/1.14.12/lib -o foo.so foo.o -L/hpc/apps/R/4.1.2/lib64/R/lib -lR
gcc -shared -L/hpc/apps/R/4.1.2/lib64/R/lib -L/hpc/apps/zlib/1.2.8/lib -L/hpc/apps/pcre/8.38/lib -L/hpc/apps/bzip2/1.0.6/lib -L/hpc/apps/curl/7.54.1/lib -L/hpc/apps/cairo/1.14.12/lib -o foo.so foo.o -L/hpc/apps/R/4.1.2/lib64/R/lib -lR
/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [foo.so] Error 1
gcc -shared -L/hpc/apps/R/4.1.2/lib64/R/lib -L/hpc/apps/zlib/1.2.8/lib -L/hpc/apps/pcre/8.38/lib -L/hpc/apps/bzip2/1.0.6/lib -L/hpc/apps/curl/7.54.1/lib -L/hpc/apps/cairo/1.14.12/lib -o foo.so foo.o -L/hpc/apps/R/4.1.2/lib64/R/lib -lR
/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [foo.so] Error 1
gcc -shared -L/hpc/apps/R/4.1.2/lib64/R/lib -L/hpc/apps/zlib/1.2.8/lib -L/hpc/apps/pcre/8.38/lib -L/hpc/apps/bzip2/1.0.6/lib -L/hpc/apps/curl/7.54.1/lib -L/hpc/apps/cairo/1.14.12/lib -o foo.so foo.o -L/hpc/apps/R/4.1.2/lib64/R/lib -lR
gcc -shared -L/hpc/apps/R/4.1.2/lib64/R/lib -L/hpc/apps/zlib/1.2.8/lib -L/hpc/apps/pcre/8.38/lib -L/hpc/apps/bzip2/1.0.6/lib -L/hpc/apps/curl/7.54.1/lib -L/hpc/apps/cairo/1.14.12/lib -o foo.so foo.o -L/hpc/apps/R/4.1.2/lib64/R/lib -lR
/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [foo.so] Error 1
/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [foo.so] Error 1
/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [foo.so] Error 1
>> setting environment variables:
PKG_LIBS = '/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/rstan/lib//libStanServices.a' -L'/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/lib/' -lStanHeaders -L'/hpc/apps/R/4.1.2/lib64/R/library/RcppParallel/lib/' -ltbb
PKG_CPPFLAGS = -I"/hpc/apps/R/4.1.2/lib64/R/library/Rcpp/include/" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/unsupported" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/BH/include" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/src/" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/" -I"/hpc/apps/R/4.1.2/lib64/R/library/RcppParallel/include/" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include '/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1
>> Program source :
>> setting environment variables:
PKG_LIBS = '/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/rstan/lib//libStanServices.a' -L'/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/lib/' -lStanHeaders -L'/hpc/apps/R/4.1.2/lib64/R/library/RcppParallel/lib/' -ltbb
PKG_CPPFLAGS = -I"/hpc/apps/R/4.1.2/lib64/R/library/Rcpp/include/" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/RcppEigen/include/unsupported" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/BH/include" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/src/" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/" -I"/hpc/apps/R/4.1.2/lib64/R/library/RcppParallel/include/" -I"/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include '/hpc/home/dinizma/R/x86_64-pc-linux-gnu-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1