stan-dev/pystan2

Running PySTAN on Windows 10

saccpp opened this issue · 5 comments

I am trying to compile the following sample code on WIN 10

import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code)
y = model.sampling().extract()['y']
print(y.mean()) # with luck the result will be near 0

The code is running from the past 30 minutes with following message

INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_5944b02c79788fa0db5b3a93728ca2bf NOW.

with no output, Can you suggest to speed up the execution?

Hi, are you running your code in jupyter notebook? See the cmd window for possible error msg.

Have you followed our Windows instructions?

https://pystan.readthedocs.io/en/latest/windows.html

Hello, I am using Spyder. I also tried cmd window, I was getting the following error

RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your child processes and you have forgotten to use the proper idiom in the main module: if name == 'main': freeze_support() ... The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable. During handling of the above exception, another exception occurred:

I followed the instruction mentioned in the link.

Ok, can you first try adding this to .sampling -> n_jobs=1.

I assume this is somekind of "bug" with multiprocessing on Windows + spyder. (in cmd the script needs to be under following block)

if __name__ == "__main__":
    #compile and sample here

Setting n_jobs=1 does compile code on Spyde in Windows.