CMDStanpy not compiling with uninformative error

Hello.

I’m running cmdstanpy with the below model.

data {
    int<lower=0> N; // number of records
    int<lower=0>  cl_pure_premium[N]; // pure premium
    vector[N] old_auto_c_score_n; //alert flag
}

parameters {
    real<lower=0> mu;
    real beta;

}

model {
       mu ~ normal(0,3);
       beta ~ normal(0,1);
       cl_pure_premium ~ poisson_log(mu + old_auto_c_score_n*beta);
}

generated quantities {
      vector[N] eta = mu + old_auto_c_score * beta;
  int y_rep[N];
  if (max(eta) > 20) {
    // avoid overflow in poisson_log_rng
    print("max eta too big: ", max(eta));
    for (n in 1:N)
      y_rep[n] = -1;
  } else {
      for (n in 1:N)
        y_rep[n] = poisson_log_rng(eta[n]);
  }
}

There is an uninformative error given below and I’m not sure what to do. I’m running this on Windows through the pycharm IDE.

C:\Users\JORDAN.HOWELL.GITDIR\AppData\Local\Continuum\anaconda3\envs\cmdstan\python.exe C:/Users/JORDAN.HOWELL.GITDIR/PycharmProjects/motorcyclebayes/models/mc_coll_bayes_model_script.py
INFO:cmdstanpy:compiling stan file C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.stan to exe file C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.exe
Traceback (most recent call last):
  File "C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes_model_script.py", line 11, in <module>
    proc_parallel_model = CmdStanModel(
  File "c:\users\jordan.howell.gitdir\src\cmdstanpy\cmdstanpy\model.py", line 215, in __init__
    raise ValueError(
ValueError: Unable to compile Stan model file: C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.stan.
INFO:cmdstanpy:deleting tmpfiles dir: C:\Users\JORDAN~1.GIT\AppData\Local\Temp\tmp49w2f7m3
INFO:cmdstanpy:done

Process finished with exit code 1

I’ve re-installed cmdstanpy already. Has anyone seen this before and know what to do?

Hi, after the compilation error, can you check the stdoutput in the temp dir?

Check the following folder

cmdstanpy._TMPDIR

and look for .txt file.

There is no file there. At the end of the error above, there is a message saying that tmpfiles are being deleted.

Ok, do you run your code with the script?

Can you try hopping into the interactive session

python -i script.py

and try again

So I ran this from the command terminal:

python -i mc_coll_bayes_model_script.py

I got this but still no file in the temp dir:

INFO:cmdstanpy:compiling stan file C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.stan to exe file C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.exe
Traceback (most recent call last):
  File "C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes_model_script.py", line 11, in <module>
    proc_parallel_model = CmdStanModel(
  File "c:\users\jordan.howell.gitdir\src\cmdstanpy\cmdstanpy\model.py", line 215, in __init__
    raise ValueError(
ValueError: Unable to compile Stan model file: C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.stan.

@WardBrian @mitzimorris did we have some keyword to pipe all output to shell?

the compile method uses the logging everywhere. I recommend setting the logging level to logging.DEBUG - cf cmdstanpy/model.py at 0b50ae9a8bfdbe011cc9eb258a6f2477d7aefc90 · stan-dev/cmdstanpy · GitHub

add these two stmts to your script:

import logging
logging.getLogger("cmdstanpy").setLevel(logging.DEBUG)

Thanks. Using that, a lot came out.

DEBUG:cmdstanpy:cmd: .\bin\stanc.exe --info C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.stan
cwd: C:\Users\JORDAN.HOWELL.GITDIR\.cmdstan\cmdstan-2.28.2
DEBUG:cmdstanpy:Command ['.\\bin\\stanc.exe', '--info', 'C:\\Users\\JORDAN.HOWELL.GITDIR\\PycharmProjects\\motorcyclebayes\\models\\mc_coll_bayes.stan']
	error during processing Operation not permitted
DEBUG:cmdstanpy:cmd: where.exe tbb.dll
cwd: None
DEBUG:cmdstanpy:TBB already found in load path
INFO:cmdstanpy:compiling stan file C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.stan to exe file C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.exe
DEBUG:cmdstanpy:cmd: mingw32-make STAN_THREADS=True STAN_OPENCL=True C:/Users/JORDAN.HOWELL.GITDIR/PycharmProjects/motorcyclebayes/models/mc_coll_bayes.exe
cwd: C:\Users\JORDAN.HOWELL.GITDIR\.cmdstan\cmdstan-2.28.2
DEBUG:cmdstanpy:Console output:

At global scope:
cc1plus.exe: warning: unrecognized command line option '-Wno-ignored-attributes'
cc1plus.exe: warning: unrecognized command line option '-Wno-ignored-attributes'
cc1plus.exe: warning: unrecognized command line option '-Wno-int-in-bool-context'
make/program:11: recipe for target 'src/cmdstan/main_threads_opencl.o' failed
mingw32-make: *** [src/cmdstan/main_threads_opencl.o] Error 1

Command ['mingw32-make', 'STAN_THREADS=True', 'STAN_OPENCL=True', 'C:/Users/JORDAN.HOWELL.GITDIR/PycharmProjects/motorcyclebayes/models/mc_coll_bayes.exe']
	error during processing No such file or directory

Traceback (most recent call last):
  File "C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes_model_script.py", line 13, in <module>
    proc_parallel_model = CmdStanModel(
  File "c:\users\jordan.howell.gitdir\src\cmdstanpy\cmdstanpy\model.py", line 215, in __init__
    raise ValueError(
ValueError: Unable to compile Stan model file: C:\Users\JORDAN.HOWELL.GITDIR\PycharmProjects\motorcyclebayes\models\mc_coll_bayes.stan.
INFO:cmdstanpy:deleting tmpfiles dir: C:\Users\JORDAN~1.GIT\AppData\Local\Temp\tmpp3b0onid
INFO:cmdstanpy:done

What compiler do you use? Have you set GPU settings correctly / added needed drivers?

I assume whatever compiler was installed when I installed cmdstanpy. My GPU works for neural nets, etc but I wasn’t aware cmdstanpy was using it

You are trying to use OpenCL? Or do you use cpu stuff from it?

I guess just CPU. I was using proc_parallel because I figured it was putting one chain on each cpu core. That was a guess though.

I ended up using this…

mc_model = os.path.join(cmdstan_path(),'examples', 'poisson', 'mc_coll.stan')
my_model = CmdStanModel(stan_file=mc_model)
my_model.name
my_model.stan_file
my_model.exe_file
my_model.code()

It compiled with no errors this time so maybe a problem with proc_parallel and my computer setup?