cmdstanpy: Unable to build Stan model

Summary:

Please provide a short couple sentence summary.

Hi,

I have been attempting to build a Stan model on an M1 Mac. Unfortunately, every time I try to build I get a message asking to rebuild cmdstan. Rebuilding is successful and results in the same error upon trying to build the Stan model again.

Description:

Describe the issue as clearly as possible.

Previously, I encountered errors such as mentioned in this ticket. I was able to successfully install cmdstanpy via conda and rebuild cmdstan:

>>> cmdstanpy.rebuild_cmdstan()
Done:  (01:14) | ███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | --- CmdStan v2.29.2 built ---
>>> exit()
INFO:cmdstanpy:deleting tmpfiles dir: /var/folders/20/d05_tk914m3ft933jzk_rmnw81m0nb/T/tmpoq35v7ht
INFO:cmdstanpy:done

And now, I am still getting the PCH file warning when trying to build my Stan model.

python 02_CmdStan_Fit.py
INFO:cmdstanpy:compiling stan file /Users/espinoal/Documents/aims_repos/daily-dose-stan-modeling/ohsu_simulator.stan to exe file /Users/espinoal/Documents/aims_repos/daily-dose-stan-modeling/ohsu_simulator
WARNING:cmdstanpy:CmdStan's precompiled header (PCH) files may need to be rebuilt.If your model failed to compile please run cmdstanpy.rebuild_cmdstan().
If the issue persists please open a bug report
Traceback (most recent call last):
  File "/Users/espinoal/Documents/aims_repos/daily-dose-stan-modeling/02_CmdStan_Fit.py", line 26, in <module>
    model = CmdStanModel(stan_file=stan_file)# compile='Force')
  File "/Users/espinoal/opt/anaconda3/envs/cmdstan/lib/python3.10/site-packages/cmdstanpy/model.py", line 210, in __init__
    raise ValueError(
ValueError: Unable to compile Stan model file: /Users/espinoal/Documents/aims_repos/daily-dose-stan-modeling/ohsu_simulator.stan.
INFO:cmdstanpy:deleting tmpfiles dir: /var/folders/20/d05_tk914m3ft933jzk_rmnw81m0nb/T/tmpdcz0aelt
INFO:cmdstanpy:done

The Stan model does build through pystan. Unfortunately with pystan, I get a vague initialization failed error when I try to sample, but I think that’s an unrelated issue.

Additional Information:

Here is the output from conda info if it is useful:

(cmdstan) MacBook-Pro:daily-dose-stan-modeling espinoal$ conda info

     active environment : cmdstan
    active env location : /Users/espinoal/opt/anaconda3/envs/cmdstan
            shell level : 2
       user config file : /Users/espinoal/.condarc
 populated config files : /Users/espinoal/.condarc
                          /Users/espinoal/opt/anaconda3/envs/cmdstan/.condarc
          conda version : 4.12.0
    conda-build version : 3.21.4
         python version : 3.8.8.final.0
       virtual packages : __osx=10.16=0
                          __unix=0=0
                          __archspec=1=arm64
       base environment : /Users/espinoal/opt/anaconda3  (writable)
      conda av data dir : /Users/espinoal/opt/anaconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-arm64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-arm64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/espinoal/opt/anaconda3/pkgs
                          /Users/espinoal/.conda/pkgs
       envs directories : /Users/espinoal/opt/anaconda3/envs
                          /Users/espinoal/.conda/envs
               platform : osx-arm64
             user-agent : conda/4.12.0 requests/2.25.1 CPython/3.8.8 Darwin/21.4.0 OSX/10.16
                UID:GID : 270140075:1971611142
             netrc file : /Users/espinoal/.netrc
           offline mode : False

Current Version:

CmdStan v2.29.2

Please let me know if I can provide additional info. Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 40 (31 by maintainers)

Most upvoted comments

We have at least 2 confirmations that the model above compiled for users running M1, so there seems to be a toolchain/stdlib issue.