My model works fine with rstan. I want to try GPU speed up so I changed my model accordingly. But when i compile I get errors:

This is my original code

```
data {
int<lower=0> N;//Number of observations
int<lower=1> J;//Number of predictors with random slope
int<lower=1> K;//Number of predictors with non-random slope
int<lower=1> L;//Number of customers/groups
int<lower=0,upper=1> y[N];//Binary response variable
int<lower=1,upper=L> ll[N];//Number of observations in groups
matrix[N,K] x1;
matrix[N,J] x2;
}
transformed data {
vector[J] ones = rep_vector(1, J);
}
parameters {
row_vector[J] rbeta_mu; //mean of distribution of beta parameters
row_vector<lower=0>[J] rbeta_sigma; //variance of distribution of beta parameters
row_vector[J] beta_raw[L]; //group-specific parameters beta
vector[K] beta;
}
transformed parameters {
matrix[L,J] rbeta;
for (l in 1:L)
rbeta[l] = rbeta_mu + rbeta_sigma .* beta_raw[l]; // coefficients on x
}
model {
vector[N] p;
rbeta_mu ~ normal(0,5);
rbeta_sigma ~ cauchy(0,5);
beta~normal(0,5);
for (l in 1:L)
beta_raw[l] ~ std_normal();
p = x1 * beta + (x2 .* rbeta[ll]) * ones; // Multiplication by vector of ones as a row-wise summation of matrix
y~bernoulli_logit(p);
}
```

This is the code i have modified for GPU speed up:

```
data {
int<lower=0> N;//Number of observations
int<lower=1> J;//Number of predictors with random slope
int<lower=1> K;//Number of predictors with non-random slope
int<lower=1> L;//Number of customers/groups
int<lower=0,upper=1> y[N];//Binary response variable
int<lower=1,upper=L> ll[N];//Number of observations in groups
matrix[N,K] x1;
matrix[N,J] x2;
}
transformed data {
vector[J] ones = rep_vector(1, J);
}
parameters {
row_vector[J] rbeta_mu; //mean of distribution of beta parameters
row_vector<lower=0>[J] rbeta_sigma; //variance of distribution of beta parameters
row_vector[J] beta_raw[L]; //group-specific parameters beta
vector[K] beta;
}
transformed parameters {
matrix[L,J] rbeta;
for (l in 1:L)
rbeta[l] = rbeta_mu + rbeta_sigma .* beta_raw[l]; // coefficients on x
}
model {
vector[N] mu;
target+=normal_lpdf(beta|0,5);
target+=cauchy_lpdf(rbeta_sigma|0,2);
target+=normal_lpdf(rbeta_mu|0,5);
for (l in 1:L)
beta_raw[l] ~ std_normal();
mu = x1 * beta + (x2 .* rbeta[ll]) * ones; // Multiplication by vector of ones as a row-wise summation of matrix
target += bernoulli_logit_lpmf(y | mu);
}
```

When i comile i get this error:

I am passing data as json.

```
model_data <- list(N=nrow(matdata1),K=ncol(matdata1),J=ncol(matdata2),x1=matdata1,x2=matdata2,y=data2$bought[1:10000],L=length(unique(data2$new_group[1:10000])),ll=data2$new_group[1:10000])
write_stan_json(model_data,"data_json.json")
opencl_options = list(
stan_opencl = TRUE,
opencl_platform_id = 0, # replace the ID based on step 3
opencl_device_id = 0 # replace the ID based on step 3
)
mod <- cmdstan_model("./gpu_stan_code.stan", cpp_options = opencl_options)
fit <- mod$sample(data = "./data_json.json", num_samples=500, num_warmup = 500, num_chains = 1, num_cores = 1)
```

I have only one GPU so have left both ids as 0.

Please help how can i resolve this.