marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
7.68k stars 266 forks source link

ConnectionResetError when using Pymc #2338

Closed lborcard closed 1 month ago

lborcard commented 1 month ago

Describe the bug

This error happens almost everytime that I open my notebook, the Pmyc model does not run and it says ConnectionResetError

  File "/usr/lib64/python3.11/multiprocessing/connection.py", line 254, in recv
    buf = self._recv_bytes()
          ^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/multiprocessing/connection.py", line 434, in _recv_bytes
    buf = self._recv(4)
          ^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/multiprocessing/connection.py", line 399, in _recv
    chunk = read(handle, remaining)
            ^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

Environment

{ "marimo": "0.8.7", "OS": "Linux", "OS Version": "4.18.0-553.8.1.el8_10.x86_64", "Processor": "x86_64", "Python Version": "3.11.9", "Binaries": { "Browser": "--", "Node": "--" }, "Requirements": { "click": "8.1.7", "importlib-resources": "missing", "jedi": "0.19.1", "markdown": "3.6", "pymdown-extensions": "10.8.1", "pygments": "2.18.0", "tomlkit": "0.12.5", "uvicorn": "0.30.1", "starlette": "0.37.2", "websockets": "12.0", "typing-extensions": "4.12.1", "ruff": "0.5.6" } }

Code to reproduce

Can be reproduced with any pymc model in my experience.

akshayka commented 1 month ago

Thanks for reporting. I have never used pymc. Can you provide a small code snippet?

lborcard commented 1 month ago

Of course there it is :

import numpy as np
import pymc as pm
# Generate synthetic data using a geometric distribution
 N0 = 1000  # Initial number of molecules
p_true = 0.1  # True decay probability
time_steps_geom = np.arange(1, 200)  # Discrete time steps
observed_data_geom = np.random.geometric(p=p_true, size=len(time_steps_geom))

# Bayesian model using PyMC
with pm.Model() as model_geom:

    p_geom = pm.Beta("p", alpha=2, beta=2)

    N_obs_geom = pm.Geometric("N_obs", p=p_geom, observed=observed_data_geom)

    trace_geom = pm.sample()

    # Get the PPC
    ppc_geom = pm.sample_posterior_predictive(trace_geom)

# Plotting the posterior distribution of p
pm.plot_posterior(trace_geom, var_names=["p"])
plt.show()
akshayka commented 1 month ago

The notebook was running for a long time so I decreased time_steps_geom to np.arange(1, 10) and that worked. Does decreasing it work for you too, or does it fail even then? Not that this is a solution but just trying to narrow in on the problem.

lborcard commented 1 month ago

it mostly throws this error when I open the notebook, i.e on start up, where part of the code is stopping because a piece of code is stopping because of this error. This particular piece of code is not the problem but just an example.

mscolnick commented 1 month ago

@lborcard this works for me too. is this ok to close?