nbanho
September 14, 2020, 12:01pm
1
Hi there,
after installing cmdstan/r, I cannot run my brm models anymore. With backend=“rstan”, I get the following error:
'C:/rtools40/usr/mingw_/bin/g++'
running command 'C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file1f5c2a3f1e3a.cpp 2> file1f5c2a3f1e3a.cpp.err.txt' had status 1cannot open file 'file1f5c2a3f1e3a.cpp.err.txt': No such file or directory
When using backend=“cmdstanr”, I get:
Compiling Stan program...
internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:186: MapViewOfFileEx: Attempt to access invalid address.
C:/Users/SpAdmin/AppData/Local/Temp/RtmpENftjs/model-1f5c2f806488.hpp:1: fatal error: had to relocate PCH
compilation terminated.
mingw32-make.exe: *** [make/program:61: C:/Users/SpAdmin/AppData/Local/Temp/RtmpENftjs/model-1f5c2f806488.exe] Error 1
If I use cmdstanr directly, the compilation works without any errors.
I would be very happy if you could help me, as otherwise I would have recode all my brm model!
Many thanks in advance.
Best,
Nic
Hi Nic,
Can you try running:
install.packages("https://cran.r-project.org/src/contrib/inline_0.3.16.tar.gz",
type="source",repos=NULL)
And try again with backend="rstan"
nbanho
September 14, 2020, 12:17pm
3
Hi Andrew,
thanks for your help! The install went well, but the error stays the same, unfortunately…
But I got more info:
make cmd is
make -f "C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-40~1.2/share/make/winshlib.mk" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file2d984746645d.dll" WIN=64 TCLBIN=64 OBJECTS="file2d984746645d.o"
make would use
"c:/rtools40/mingw64/bin/"g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I"C:/Program Files/R/R-4.0.2/library/Rcpp/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppEigen/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppEigen/include/unsupported" -I"C:/Program Files/R/R-4.0.2/library/BH/include" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/src/" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppParallel/include/" -I"C:/Program Files/R/R-4.0.2/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include "C:/Program Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp" -std=c++1y -include C:/Program Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I "C:/Program Files/R/R-4.0.2/library/StanHeaders/include" -I "C:/Program Files/R/R-4.0.2/library/RcppEigen/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c file2d984746645d.cpp -o file2d984746645d.o
if test "zfile2d984746645d.o" != "z"; then \
if test -e "file2d984746645d-win.def"; then \
echo "c:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file2d984746645d.dll file2d984746645d-win.def file2d984746645d.o "C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ; \
"c:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file2d984746645d.dll file2d984746645d-win.def file2d984746645d.o "C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ; \
else \
echo EXPORTS > tmp.def; \
"c:/rtools40/mingw64/bin/"nm file2d984746645d.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^ ][^ ]*/"&"/g' >> tmp.def; \
echo "c:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file2d984746645d.dll tmp.def file2d984746645d.o "C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ; \
"c:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file2d984746645d.dll tmp.def file2d984746645d.o "C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ; \
rm -f tmp.def; \
fi \
fi
When you say “the error stays the same”, do you mean the No such file or directory
error?
nbanho
September 14, 2020, 12:21pm
5
Yes, so this one:
Compiling Stan program...
'C:/rtools40/usr/mingw_/bin/g++' not foundincomplete final line found on 'C:/Users/SpAdmin/Documents/.R/Makevars.win'incomplete final line found on 'C:/Users/SpAdmin/Documents/.R/Makevars.win
From what I have read, the second one (‘final line not found’) is not important
The 'C:/rtools40/usr/mingw_/bin/g++' not found
is safe to ignore, it’s a harmless warning that will be removed in the next release. Do you have any issues aside from that?
nbanho
September 14, 2020, 12:24pm
7
Ah okay, well the problem is the model is not running and, at least that is what I thought, due to the above error…
Progress at least! What do you mean by ‘not running’?
nbanho
September 14, 2020, 12:28pm
9
It is not sampling, nothing is happening when I run:
m <- brm(y ~ 0 + Intercept + (1 | user) + x1+ x2+ x3,
data = df, family = binomial(link = "logit"), prior = priors,
seed = 1234)
Only getting the above messages, here are all messages:
Using the maximum response value as the number of trials.
Using 'binomial' families without specifying 'trials' on the left-hand side of the model formula is deprecated.Only 2 levels detected so that family 'bernoulli' might be a more efficient choice.
Compiling Stan program...
'C:/rtools40/usr/mingw_/bin/g++' not foundincomplete final line found on 'C:/Users/SpAdmin/Documents/.R/Makevars.win'incomplete final line found on 'C:/Users/SpAdmin/Documents/.R/Makevars.win'make cmd is
make -f "C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-40~1.2/share/make/winshlib.mk" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file2d983e3131d3.dll" WIN=64 TCLBIN=64 OBJECTS="file2d983e3131d3.o"
make would use
"c:/rtools40/mingw64/bin/"g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I"C:/Program Files/R/R-4.0.2/library/Rcpp/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppEigen/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppEigen/include/unsupported" -I"C:/Program Files/R/R-4.0.2/library/BH/include" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/src/" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppParallel/include/" -I"C:/Program Files/R/R-4.0.2/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include "C:/Program Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp" -std=c++1y -include C:/Program Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I "C:/Program Files/R/R-4.0.2/library/StanHeaders/include" -I "C:/Program Files/R/R-4.0.2/library/RcppEigen/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c file2d983e3131d3.cpp -o file2d983e3131d3.o
if test "zfile2d983e3131d3.o" != "z"; then \
if test -e "file2d983e3131d3-win.def"; then \
echo "c:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file2d983e3131d3.dll file2d983e3131d3-win.def file2d983e3131d3.o "C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ; \
"c:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file2d983e3131d3.dll file2d983e3131d3-win.def file2d983e3131d3.o "C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ; \
else \
echo EXPORTS > tmp.def; \
"c:/rtools40/mingw64/bin/"nm file2d983e3131d3.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^ ][^ ]*/"&"/g' >> tmp.def; \
echo "c:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file2d983e3131d3.dll tmp.def file2d983e3131d3.o "C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ; \
"c:/rtools40/mingw64/bin/"g++ -shared -s -static-libgcc -o file2d983e3131d3.dll tmp.def file2d983e3131d3.o "C:/Program Files/R/R-4.0.2/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.2/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.2/library/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-40~1.2/bin/x64" -lR ; \
rm -f tmp.def; \
fi \
fi
I thought the g++ not found was the error, but now I start wondering what the error is here. Sorry if I am missing something
Alright, the first step is to troubleshoot your rstan installation.
Can you run the rstan example model:
library(rstan)
example(stan_model,run.dontrun=TRUE,verbose=TRUE)
And post any lines that start with error:
?
nbanho
September 14, 2020, 12:40pm
11
Error in compileCode(f, code, language = language, verbose = verbose) :
g++.exe: error: Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorymake: *** [C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf:229: file2d9875cc1ee3.o] Error 1
Great! I think your StanHeaders package might be out of date. Can you try updating your StanHeaders and rstan:
install.packages(c("StanHeaders","rstan"))
And then try the example model again?
2 Likes
nbanho
September 14, 2020, 12:51pm
13
That did it! The example ran without errors and my brm models are also sampling now. Thank you so much for your great help :)
2 Likes