Error running R code on Linux computing cluster

Hi all,

I’m trying to run my R code on a remote server (Linux computing cluster). I’ve succesully installed the necessary R packages to the server such as rstan and loo packages. However, when submitting a job to the server, the following warning and error messages appear:

During startup - Warning messages:
1: Setting LC_CTYPE failed, using “C”
2: Setting LC_COLLATE failed, using “C”
3: Setting LC_TIME failed, using “C”
4: Setting LC_MESSAGES failed, using “C”
5: Setting LC_MONETARY failed, using “C”
6: Setting LC_PAPER failed, using “C”
7: Setting LC_MEASUREMENT failed, using “C”

Loading required package: ggplot2
Loading required package: StanHeaders
rstan (Version 2.17.3, 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)
This is loo version 2.0.0.
**NOTE: As of version 2.0.0 loo defaults to 1 core but we recommend using as many as possible. Use the ‘cores’ argument or set options(mc.cores = NUM_CORES) for an entire session. Visit mc-stan.org/loo/news for details on other changes.
Error in system2(file.path(R.home(component = “bin”), “R”), args = paste(“CMD config”, : **
** error in running command

Calls: stan_model -> get_CXX -> system2
Execution halted

Any idea how can I solve this problem? Is it somehow related to installing Xcode on the server? and how can I do this?

Given that I can run the R code on my Mac laptop without any problems.

Thanks

You can’t install Xcode on a Linux server, but you don’t need to because it should already have a C++ toolchain. Can you run rstan:::get_CXX() on the login node of the cluster? Due to all the Setting LC_* warning messages, it may be a problem with localization of the quotation marks.

Hi bgoodri,

Thank you for your reply. I’m new to linux remote server.

What I just did, connect to the linux server, load R and run the script: rstan:::get_CXX(). I got the following output: “g++”

I can run the R code directly when I load R on the server. That is, I write the command: “module load R”, then I copy and paste the R code and it works. But this is not practical since it only uses one node as I’m running it on my laptop.

The problem occurs when submitting the job to the server using the command:
sbatch command.

What do you mean by “localization of the quotation marks.” ?

OK. The execute nodes are for some reason not finding g++ or are not finding the necessary MAKEVARS files. Try to run a script that just has

system2(file.path(R.home(component = "bin"), "R"), 
                args = "CMD config CXX")

to see if you get a better error message.

Ok. I submitted a job with the script you specified. Here is what I get in the output file:

During startup - Warning messages:
1: Setting LC_CTYPE failed, using “C”
2: Setting LC_COLLATE failed, using “C”
3: Setting LC_TIME failed, using “C”
4: Setting LC_MESSAGES failed, using “C”
5: Setting LC_MONETARY failed, using “C”
6: Setting LC_PAPER failed, using “C”
7: Setting LC_MEASUREMENT failed, using “C”
/opt/ohpc/pub/libs/gnu7/R/3.4.2/lib64/R/bin/config: line 177: make: command not found
/opt/ohpc/pub/libs/gnu7/R/3.4.2/lib64/R/bin/config: line 178: make: command not found
/opt/ohpc/pub/libs/gnu7/R/3.4.2/lib64/R/bin/config: line 179: make: command not found
/opt/ohpc/pub/libs/gnu7/R/3.4.2/lib64/R/bin/config: line 180: make: command not found
/opt/ohpc/pub/libs/gnu7/R/3.4.2/lib64/R/bin/config: line 181: make: command not found
/opt/ohpc/pub/libs/gnu7/R/3.4.2/lib64/R/bin/config: line 313: make: command not found

You are probably going to have to take that up with the system administrator for the cluster. In any event, a Stan model is not going to compile if it cannot find make.

As an alternative, you may be able to compile the model once on the login node after calling

rstan_options(auto_write = TRUE)

and the execute nodes should be able to load the compiled model from the disk without recompiling it.

Ok. I’m going to try both options and see how it goes. Thank you so much for your help

Hi Rehab,
I am exactly the same errors as you. How did you solve this in the end? rstan_options(auto_write=TRUE) is not enough for my code to use rstan.

A Linux cluster is going to have make on it. This is more an issue of talking with the system administrator to see how to get it onto the user’s PATH for the workflows supported by that cluster.

Did you load the R module in the job script? Whenever I submit a single R script with sbatch, my slurm script usually looks something like this:

#SBATCH -J job_name
#SBATCH -N 1 
### More sbatch commands
####
module load Rstats
Rscript path/to/script.r arg1 arg2 arg3 # etc. on commandArgs

There should be some way of opening an interactive job on a compute/execute node (depending on how your cluster is configured). It may be worth launching one and figuring out how to make it work there.

Hi Johanna,

Here is the link for the solution:

First, I compiled the stan code without the data, directly on the management node and saved the compiled file with extension .RData. This takes few seconds.
Then, in the R file, I added a statement to call the compiled file. After that, you can submit the R file to the SLURM.

Here is my previous answer after the discussion with members of stan forums:

“ But I found a solution to get around the compilation error. First, I compiled the stan model, without data, on the “Management Server” and saved the compiled model with the extension .RData as follow:

sm ← stan_model(file = ‘a.stan’, save_dso = TRUE)
save(‘sm’, file = ‘sm.RData’)

Then, I submitted my R file to the SLURM and it works :)

The R file includes the following:

load(“sm.RData”)

… simulated data…

fit ← sampling(sm, data=list(K, N, J, y, dir_alpha ), pars=c(“pi”, “mu”, “theta”, “beta”, “alpha”, “prob”), warmup = 2000, iter = 5000, chains = 3)

Thanks a lot for everyone helped to solve this problem. Thanks for the Stan forums.”