Issues with c++ and brms_multiple

It now just hangs here:

brms_multiple model

m2 ← brm_multiple(purge01 ~ 1 + (1|s1), data=imp1, verbose=T)
Compiling the C++ model

CHECKING DATA AND PREPROCESSING FOR MODEL ‘0c166cd5fcfd2d705d7f2b7d3a244928’ NOW.

COMPILING MODEL ‘0c166cd5fcfd2d705d7f2b7d3a244928’ NOW.

STARTING SAMPLER FOR MODEL ‘0c166cd5fcfd2d705d7f2b7d3a244928’ NOW.

Heading into class, but I will try installing cmdstanr and see if that works!

1 Like

Yes, the cmdstan backend is much better imho. Just install cmdstanr which will help you install cmdstan. Then use backend = "cmdstanr" in brms.

Ok, so unfortunately, installing gfortran did not seem to work; although I realized I have Mojave, it did seem to install and I added the Makevars file to the .R/ directory & restarted RStudio. This is what I get when running a sample model (see attached). error.txt (35.3 KB)

I will now try cmdstan on the server!

the cmdstan seems to work, including with brm_multiple!! :) Or at least the sampling started and I got normal-ish looking output, however, I get this error:

Fitting imputed model 18
Running MCMC with 1 chain...

Chain 1 WARNING: No variance estimation is 
Chain 1          performed for num_warmup < 20 
Chain 1 Iteration: 1 / 2 [ 50%]  (Warmup) 
Chain 1 Iteration: 2 / 2 [100%]  (Sampling) 
Chain 1 finished in 0.0 seconds.
Start sampling
Error in read_cmdstan_csv(self$output_files(), variables = "", sampler_diagnostics = if (!fixed_param) c("treedepth__",  : 
  Assertion on 'files' failed: File does not exist: '/d/q1/7055912.1.linux01.q/RtmpVF1H0i/file36a753b338-202103051035-1-58da21.csv'.
Calls: brm_multiple -> <Anonymous> -> value.Future -> signalConditions
In addition: There were 18 warnings (use warnings() to see them)
Execution halted

I had 30 imputed datasets, so I’m not sure why this happened just over halfway through. Do you know what this error is? Thank you so much.

According to your error msg no C++ compiler was found on your system.

I presume you ran this in a shell?

xcode-select --install

You should download the Mojave version of gfortran and install that one. Make sure to change Makevars also to the new path, which differs for Mojave!

It seems it’s placed a file in directory /d which it can’t find? Very peculiar. Are you having a networked disc?

I am in the process of downloading xcode on my computer and looking for the Mojave gfortran, which I will try after my classes.

I am not sure how to know whether I am on a network disc or not, however, I looked and the file that R is telling me doesn’t exist does indeed exist. I re-ran the model, got this error:

Error in read_cmdstan_csv(self$output_files(), variables = "", sampler_diagnostics = if (!fixed_param) c("treedepth__",  : 
  Assertion on 'files' failed: File does not exist: '/d/q1/7056309.1.linux01.q/TMP/Rtmp48GraG/file755ca5e6a3c-202103051304-1-804455.csv'.

And then checked for that file:

list.files(“/d/q1/7056309.1.linux01.q/TMP/Rtmp48GraG”)
[1] “callr-env-755c61344bc2”
[2] “file755ca5e6a3c”
[3] “file755ca5e6a3c-202103051305-1-804455.csv”
[4] “file755ca5e6a3c-202103051305-2-804455.csv”
[5] “file755ca5e6a3c-202103051305-3-804455.csv”
[6] “file755ca5e6a3c.stan”
[7] “model-755c697bca90”
[8] “model-755c697bca90.hpp”
[9] “model-755c697bca90.stan”
[10] “releases-755c3abd3da4.json”
[11] “standata-755c149ff60c.json”
[12] “standata-755c1bbca63c.json”
[13] “standata-755c1c469cee.json”
[14] “standata-755c1d87660d.json”
[15] “standata-755c239c3148.json”
[16] “standata-755c277c24cd.json”
[17] “standata-755c2dcc7f30.json”
[18] “standata-755c302c4cb1.json”
[19] “standata-755c30a0c645.json”
[20] “standata-755c335195af.json”
[21] “standata-755c349ad7e1.json”
[22] “standata-755c34dd291e.json”
[23] “standata-755c362bd524.json”
[24] “standata-755c39b3d93e.json”
[25] “standata-755c3bc0b97.json”
[26] “standata-755c3fba5c81.json”
[27] “standata-755c4586d39f.json”
[28] “standata-755c497ee13f.json”
[29] “standata-755c4a6cf011.json”
[30] “standata-755c4c2e85b2.json”
[31] “standata-755c511520a2.json”
[32] “standata-755c5119b855.json”
[33] “standata-755c581da3d3.json”
[34] “standata-755c64527ee.json”
[35] “standata-755c6506556a.json”
[36] “standata-755c6a24e895.json”
[37] “standata-755c6a2caa98.json”
[38] “standata-755c724ffb2c.json”
[39] “standata-755c74bccbb4.json”
[40] “standata-755c7f55811a.json”
[41] “standata-755cb67b1c0.json”

So that’s super weird, and not sure what to do next!

This is very strange. However, since you have Mojave I would recommend you to follow these instructions: R Compiler Tools for Rcpp on macOS | The Coatless Professor

thank you, I will do that now! Do you think the issue on the server is something server-specific? I’m thinking I should reach out to their IT department …

I personally have had lots of problems using networked discs when doing computations so all prototyping I always do on my laptop or on a cluster where all discs are local.

Thank you so much again for all of your help. So I ended up getting brms_multiple to work over the server with sample data from the mice package (the nhanes dataframe). The model runs fine, although I do get the following error, repeated five times (for the five imputed datasets):

1: UNRELIABLE VALUE: Future (‘<none>’) unexpectedly generated random numbers without specifying argument 'seed'. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'seed=NULL', or set option 'future.rng.onMisuse' to "ignore".

However, when I use the brms_multiple on my data, I get the strange error that it can’t find a file all of a sudden:

Error in read_cmdstan_csv(self$output_files(), variables = "", sampler_diagnostics = if (!fixed_param) c("treedepth__",  : 
  Assertion on 'files' failed: File does not exist: '/d/q1/7062827.1.linux01.q/TMP/RtmpbGh2A3/file6075feb6a64-202103081019-1-51f92d.csv'.

And interestingly, I get this same error on the nhanes data example if I specify more than 1 core in the brms_multiple command.

I’m emailing the IT department for the server, but not sure if you have any more thoughts on this (or know about the error associated with setting the seed?) Thank you!!

update is everything works now lol! so it is possible to use brms_multiple over a server.

1 Like