stan-dev / cmdstanpy

CmdStanPy is a lightweight interface to Stan for Python users which provides the necessary objects and functions to compile a Stan program and fit the model to data using CmdStan.
BSD 3-Clause "New" or "Revised" License
151 stars 69 forks source link

fit.summary() not working in jupyter notebooks #744

Open filippoferrari opened 5 months ago

filippoferrari commented 5 months ago

Summary:

fit.summary() crashes when run in a jupyter notebook.

Description:

fit.summary() and fit.diagnose() don't work when following the Hello World tutorial in a jupyter notebook.

The tutorial works fine when run as a python file.

Additional Information:

Error RuntimeError: Command ['/Users/ff/.cmdstan/cmdstan-2.34.1/bin/diagnose', '/var/folders/2r/tmwm99ns51qfspk50vj23snh0000gn/T/tmpvoigfpsl/bernoulliomselojt/bernoulli-20240408175756_1.csv', '/var/folders/2r/tmwm99ns51qfspk50vj23snh0000gn/T/tmpvoigfpsl/bernoulliomselojt/bernoulli-20240408175756_2.csv', '/var/folders/2r/tmwm99ns51qfspk50vj23snh0000gn/T/tmpvoigfpsl/bernoulliomselojt/bernoulli-20240408175756_3.csv', '/var/folders/2r/tmwm99ns51qfspk50vj23snh0000gn/T/tmpvoigfpsl/bernoulliomselojt/bernoulli-20240408175756_4.csv'] terminated by signal 6 Unknown error: -6

Current Version:

INSTALLED VERSIONS
---------------------
python: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:54:21) [Clang 16.0.6 ]
python-bits: 64
OS: Darwin
OS-release: 23.4.0
machine: arm64
processor: arm
byteorder: little
LC_ALL: None
LANG: None
LOCALE: (None, 'UTF-8')
cmdstan_folder: /Users/ff/.cmdstan/cmdstan-2.34.1
cmdstan: (2, 34)
cmdstanpy: 1.2.2
pandas: 2.2.1
xarray: 2024.3.0
tqdm: 4.66.2
numpy: 1.26.4
WardBrian commented 5 months ago

I wonder if this has something to do with one being run under ARM and one under x86

Did you install cmdstan with conda or with install_cmdstan?

filippoferrari commented 5 months ago

It was through conda - it's quite weird because, when I run the notebook, all the processes in the activity monitor are ARM.

I tried to run install_cmdstan from a notebook and it fails, while it works fine through repl in the terminal.

WardBrian commented 5 months ago

Are all the processes in ARM when run from the terminal as well?

filippoferrari commented 5 months ago

From what I can see yes - unless they're so quick that they won't show in the activity monitor

WardBrian commented 5 months ago

From the jupyter notebook, can you try running the commands directly? Even just !/Users/ff/.cmdstan/cmdstan-2.34.1/bin/diagnose --help might be helpful to see the output of

filippoferrari commented 5 months ago

Hi Brian, Apologies for the slow reply. !/Users/ff/.cmdstan/cmdstan-2.34.1/bin/diagnose --help returns zsh:1: no such file or directory: /Users/ff/.cmdstan/cmdstan-2.34.1/bin/diagnose both from jupyter and command line. The example notebook still runs though.

This is the content of

> ls /Users/ff/.cmdstan/cmdstan-2.34.1/bin/

linux-stanc   mac-stanc     stanc         windows-stanc
WardBrian commented 5 months ago

Very odd that those files are now missing - it sounds similar to some sporadic issues we've heard with code signing: https://discourse.mc-stan.org/t/cmdstanpy-reduce-sum-doesnt-produce-executable/33637/14

This seems to be an OS issue for the newer macs where sometimes they think an executable is invalid and delete it.

filippoferrari commented 5 months ago

Thank you, I wasn't aware of this issue. When I get some time I'll see if other installation methods would fix this