Compilation error on Linux server


#1

Hi all,

I’m trying to run my stan code, using rstan package, on linux server,
It seems there is an error in compiling the stan code. Here is the Error message I get:

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
*** caught illegal operation ***
address 0x7f159115307a, cause ‘illegal operand’

Traceback:

1: dyn.load(file, DLLpath = DLLpath, …)

2: library.dynam(lib, package, package.lib)

3: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])

4: asNamespace(ns)

5: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from$

6: loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]])

7: namespaceImport(ns, loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]), from = package)

8: loadNamespace(package, lib.loc)

9: doTryCatch(return(expr), name, parentenv, handler)

10: tryCatchOne(expr, names, parentenv, handlers[[1L]])

11: tryCatchList(expr, classes, parentenv, handlers)

12: tryCatch({ attr(package, “LibPath”) <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamesp$

13: library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc, quietly = quietly)

14: .getRequiredPackages2(pkgInfo, quietly = quietly)

15: library(rstan)

An irrecoverable exception occurred. R is aborting now …

/var/spool/slurm/d/job18982/slurm_script: line 18: 17625 Illegal instruction Rscript /home/rhakmani/2PLG2.R

The content of Makevars file (~/.R/Makevars) is below:

CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined

CXXFLAGS+=-flto -Wno-unused-local-typedefs

CXXFLAGS += -Wno-ignored-attributes -Wno-deprecated-declarations

CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined

CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -Wno-macro-redefined

I greatly appreciate any suggestion to solve this problem.

Thank you


#2

Looks like someone else had a similar problem: Using Rstan on a cluster


#3

You are right. We have the same problem becuase we are using the same server


#4

Try removing
“-mtune=native -march=native” from the CFLAGS. It is likely that you have a heterogeneous server architecture on your cluster. The model is likely compiled once on one node, and then tried to run on a different node with a different CPU, and so it fails. If you remove those CFLAGS, it will be compiled to work on any cpu.

I had a similar issue and spent some time creating a script that would inspect the CPU architecture and maintain a separate copy of the compiled model for each installation. However, it turned out that the -march=native -mtune=native flags didn’t really speed things up very much, so I abandoned this strategy. I also found that the -O3 flags added a lot to compile time, and did not produce the speed improvements that I expected, so I now use:

CXXFLAGS= -O2 -pipe -Wno-unused -DEIGEN_NO_DEBUG -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -DNO_FPRINTF_OUTPUT -std=c++11 

Using Rstan on a cluster
#5

Thank you aaronjg for your reply.
I did what you suggested and removed the statement. However, I got the same error message. In a second trial, I removed the -O3 flags and added yours but nothing changed. The sanme error message appeared.


#6

Do you have auto write turned on? It may not be recompiling. Check the project directory for .rds files that are storing the compiled model, if you find these, try deleting them and rerunning.


#7

Do you mean this code: rstan_options(auto_write = TRUE)
No, I do not use it.
There is not any file with the extension .rds in the directory.


#8

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”

For what it’s worth, these warning messages suggest R is having trouble with the locale. I’ve run into locale trouble on my Linux desktop before, and it caused strange behaviors. You may wish to check if that’s the problem (one possible solution is here, and others can be easily found on google).