Thanks!
UPDATE - @rok_cesnovar @ahartikainen I updated g++ to 4.9.3 and cmdstan2-24 was successfully build. Thank you so much.
I tried to reduce the example and noticed that compiling model without data causes it to segfault
This segfaults
import stan
import numpy as np
import logging
logging.basicConfig(level=logging.DEBUG)
program_code = """
data {
int W;
int N;
int AAA;
int BBB;
vector[BBB] U[N,W];
}
parameters {
vector[AAA] X[N,W];
matrix[AAA, AAA] A;
matrix[AAA, BBB] B;
}
model {
to_vector(A) ~ normal(0,1);
to_vector(B) ~ normal(0,1);
for (w in 1:W) {
for (n in 1:N) {
if (w == 1) {
X[n,w] ~ normal(0,1);
}
else {
X[n,w] ~ normal((A * X[n,w] + B * U[n,w-1]), 1);
}
}
}
}"""
print("Starting the building process")
posterior = stan.build(program_code, data={})
print("Done")
This doesn’t crash
import stan
import numpy as np
import logging
logging.basicConfig(level=logging.DEBUG)
program_code = """
data {
int W;
int N;
int AAA;
int BBB;
vector[BBB] U[N,W];
}
parameters {
vector[AAA] X[N,W];
matrix[AAA, AAA] A;
matrix[AAA, BBB] B;
}
model {
to_vector(A) ~ normal(0,1);
to_vector(B) ~ normal(0,1);
for (w in 1:W) {
for (n in 1:N) {
if (w == 1) {
X[n,w] ~ normal(0,1);
}
else {
X[n,w] ~ normal((A * X[n,w] + B * U[n,w-1]), 1);
}
}
}
}"""
print("Starting the building process")
posterior = stan.build(program_code, data={
"W" : 3,
"N" : 2,
"AAA" : 4,
"BBB" : 5,
"U" : np.random.randn(2, 3, 5),
})
print("Done")
Still need to figure out the minimal example which fails.
Added two issues
empty data
this model
Thanks for addressing this! Does it mean that something is wrong with my model? (I bet many things are wrong with my model.)
segfault is fault in our end.
But, there might be something wrong with your data?
E.g. is end
used in the function? Is all parameters used in the model / function for user function?
Nope, I just use start
as a participant index (the idea behind this design was to run all N
s in parallel). Hope this is implemented correctly.
Yes. I don’t think there are unused parameters. There are missing parameters that Stan imputes and that are used for expressions like alpha_rdm_pr[n,w] ~ normal(C[1,] * X[n,w],sigma_r);