I have a cmdstanr programme that runs in R studio but doesn’t run on a computer cluster via MacOS Terminal. To try to overcome various problems I have encountered while trying to run the same programme on a computer cluster using Terminal, I have compiled the stan model in my local environment, then moved the resulting .exe file to the directory that I use when on the cluster. However, when I run this programme on Terminal, I run into the following problem:
> set_cmdstan_path("/storage/users/gmilne/test/.cmdstanr/cmdstan-2.25.0")
CmdStan path set to: /storage/users/gmilne/test/.cmdstanr/cmdstan-2.25.0
> file <- "stan_mod_simple.stan"
> compile_mod <- cmdstan_model(file)
Model executable is up to date!
> # fit the model to the data
> fit <- compile_mod$sample(
+ data = data_si,
+ seed = 123,
+ chains = 3,
+ parallel_chains = 3,
+ iter_warmup = 5,
+ iter_sampling = 10,
+ refresh = 1
+ )
Running MCMC with 3 parallel chains...
Chain 1 ./stan_mod_simple: ./stan_mod_simple: cannot execute binary file
Chain 2 ./stan_mod_simple: ./stan_mod_simple: cannot execute binary file
Chain 3 ./stan_mod_simple: ./stan_mod_simple: cannot execute binary file
Warning: Chain 1 finished unexpectedly!
Warning: Chain 2 finished unexpectedly!
Warning: Chain 3 finished unexpectedly!
Warning: Use read_cmdstan_csv() to read the results of the failed chains.
Warning messages:
1: All chains finished unexpectedly!
2: No chains finished successfully. Unable to retrieve the fit.
Which is strange because the Model executable is up to date!
part suggests to me that the compiled model code is there and ready to use. When checking the architecture of the .exe file in a Terminal command, I find that it is a .64-bit file (the same as my operating system):
file test/stan_mod_simple
Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>
I have previously attempted various other workarounds, including using the stanc2 compiler instead (as suggested here CmdStan on ARM error - #6 by asceles) while compiling the model on the cluster instead of my local environment. This results in a syntax error, as seen below, I suppose since my stan code is using the syntax from cmdstanr that the older compiler might not understand?
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Variable "mod_si" does not exist.
error in '/var/folders/8w/byg0q9bx7r9bk20hswzlnh700000gn/T/RtmpnWDJlA/model-6b1d2dd99afc.stan' at line 205, column 10
-------------------------------------------------
203: //run solver
204: y = ode_rk45_tol(
205: mod_si, //model function
^
206: init, //vector initial values
-------------------------------------------------
make: *** [/var/folders/8w/byg0q9bx7r9bk20hswzlnh700000gn/T/RtmpnWDJlA/model-6b1d2dd99afc.hpp] Error 253
Error: An error occured during compilation! See the message above for more information.
I would greatly appreciate any advice on what I might be doing wrong. Ideally I’d like to be able to compile the Stan model in my local environment and upload this to the directory I use while using the cluster. I’m not sure if the strategy I’m currently using is the correct one. I haven’t uploaded my model code here since it is quite long and it runs fine on my R studio local environment. I’d be happy to provide any additional information. Thanks.
Background info:
- Operating System: macOS Mojave 10.14.6
- R Version 4.0.3
- CmdStan Version: cmdstan-2.25