Multiprocess crash

Many thanks for the suggestion. I tried the setting and got the folowing error log. Do you have any further suggestion?

---------------------------------------------------------------------------
RemoteTraceback                           Traceback (most recent call last)
RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/vm.py", line 1235, in make_all
    node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/op.py", line 119, in make_thunk
    return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/op.py", line 84, in make_c_thunk
    outputs = cl.make_thunk(
              ^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1209, in make_thunk
    cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
                                                             ^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1129, in __compile__
    thunk, module = self.cthunk_factory(
                    ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1653, in cthunk_factory
    module = cache.module_from_key(key=key, lnk=self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/cmodule.py", line 1197, in module_from_key
    module = self._get_from_hash(module_hash, key)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/cmodule.py", line 1100, in _get_from_hash
    with lock_ctx():
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/compile/compilelock.py", line 74, in lock_ctx
    fl.acquire(timeout=timeout)
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/filelock/_api.py", line 264, in acquire
    raise Timeout(lock_filename)  # noqa: TRY301
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
filelock._error.Timeout: The file lock '/home/user/.pytensor/compiledir_Linux-3.10-el7.x86_64-x86_64-with-glibc2.17-x86_64-3.11.7-64/.lock' could not be acquired.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/tmp/ipykernel_259166/1255918468.py", line 59, in single_round_simulation
    idata = pm.sample(draws=chain_len, chains=1)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/sampling/mcmc.py", line 689, in sample
    step = assign_step_methods(model, step, methods=pm.STEP_METHODS, step_kwargs=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/sampling/mcmc.py", line 239, in assign_step_methods
    return instantiate_steppers(model, steps, selected_steps, step_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/sampling/mcmc.py", line 140, in instantiate_steppers
    step = step_class(vars=vars, model=model, **args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/step_methods/hmc/nuts.py", line 180, in __init__
    super().__init__(vars, **kwargs)
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/step_methods/hmc/base_hmc.py", line 109, in __init__
    super().__init__(vars, blocked=blocked, model=self._model, dtype=dtype, **pytensor_kwargs)
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/step_methods/arraystep.py", line 164, in __init__
    func = model.logp_dlogp_function(vars, dtype=dtype, **pytensor_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/model/core.py", line 618, in logp_dlogp_function
    return ValueGradFunction(costs, grad_vars, extra_vars_and_values, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/model/core.py", line 350, in __init__
    self._pytensor_function = compile_pymc(inputs, outputs, givens=givens, **kwargs)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pymc/pytensorf.py", line 991, in compile_pymc
    pytensor_function = pytensor.function(
                        ^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/compile/function/__init__.py", line 315, in function
    fn = pfunc(
         ^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/compile/function/pfunc.py", line 469, in pfunc
    return orig_function(
           ^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/compile/function/types.py", line 1762, in orig_function
    fn = m.create(defaults)
         ^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/compile/function/types.py", line 1654, in create
    _fn, _i, _o = self.linker.make_thunk(
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/basic.py", line 245, in make_thunk
    return self.make_all(
           ^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/vm.py", line 1244, in make_all
    raise_with_op(fgraph, node)
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/utils.py", line 531, in raise_with_op
    raise exc_value.with_traceback(exc_trace)
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/vm.py", line 1235, in make_all
    node.op.make_thunk(node, storage_map, compute_map, [], impl=impl)
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/op.py", line 119, in make_thunk
    return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/op.py", line 84, in make_c_thunk
    outputs = cl.make_thunk(
              ^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1209, in make_thunk
    cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
                                                             ^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1129, in __compile__
    thunk, module = self.cthunk_factory(
                    ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1653, in cthunk_factory
    module = cache.module_from_key(key=key, lnk=self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/cmodule.py", line 1197, in module_from_key
    module = self._get_from_hash(module_hash, key)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/link/c/cmodule.py", line 1100, in _get_from_hash
    with lock_ctx():
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/pytensor/compile/compilelock.py", line 74, in lock_ctx
    fl.acquire(timeout=timeout)
  File "/home/user/miniforge3/envs/pymc_env0/lib/python3.11/site-packages/filelock/_api.py", line 264, in acquire
    raise Timeout(lock_filename)  # noqa: TRY301
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
filelock._error.Timeout: The file lock 'The file lock '/home/user/.pytensor/compiledir_Linux-3.10-el7.x86_64-x86_64-with-glibc2.17-x86_64-3.11.7-64/.lock' could not be acquired.
Apply node that caused the error: Composite{(i5 - (i2 + (i3 * i4) + (i0 * i1)))}(ExpandDims{axis=0}.0, [-4.045692 ... 74900e+00], ExpandDims{axis=0}.0, ExpandDims{axis=0}.0, [0. 1. 1. ... 1. 0. 0.], Y_obs1{[-2.025834 ... 00053e+00]})
Toposort index: 6
Inputs types: [TensorType(float64, shape=(1,)), TensorType(float64, shape=(1000,)), TensorType(float64, shape=(1,)), TensorType(float64, shape=(1,)), TensorType(float64, shape=(1000,)), TensorType(float64, shape=(1000,))]

HINT: Use a linker other than the C linker to print the inputs' shapes and strides.
HINT: Re-running with most PyTensor optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the PyTensor flag 'optimizer=fast_compile'. If that does not work, PyTensor optimizations can be disabled with 'optimizer=None'.
HINT: Use the PyTensor flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node.' could not be acquired.
"""

The above exception was the direct cause of the following exception:

Timeout                                   Traceback (most recent call last)
Cell In[8], line 25
     12 temp_reses = [ # return 
     13     pool.apply_async(
     14         single_round_simulation, # function
   (...)
     17     for RANDOM_SEED in range(nrepeat) # 随机种子
     18 ]
     19 for temp_resi in tqdm(temp_reses, desc="Pipeline: "):
     20     ( # 函数的return
     21         mcmc_betas_mean, 
     22         mcmc_betas_std, 
     23         ols_betas_mean, 
     24         ols_betas_std
---> 25     ) = temp_resi.get()
     26     mcmc_betas_mean_l.append(mcmc_betas_mean)
     27     mcmc_betas_std_l.append(mcmc_betas_std)

File ~/miniforge3/envs/pymc_env0/lib/python3.11/multiprocessing/pool.py:774, in ApplyResult.get(self, timeout)
    772     return self._value
    773 else:
--> 774     raise self._value

Timeout: The file lock 'The file lock '/home/user/.pytensor/compiledir_Linux-3.10-el7.x86_64-x86_64-with-glibc2.17-x86_64-3.11.7-64/.lock' could not be acquired.
Apply node that caused the error: Composite{(i5 - (i2 + (i3 * i4) + (i0 * i1)))}(ExpandDims{axis=0}.0, [-4.045692 ... 74900e+00], ExpandDims{axis=0}.0, ExpandDims{axis=0}.0, [0. 1. 1. ... 1. 0. 0.], Y_obs1{[-2.025834 ... 00053e+00]})
Toposort index: 6
Inputs types: [TensorType(float64, shape=(1,)), TensorType(float64, shape=(1000,)), TensorType(float64, shape=(1,)), TensorType(float64, shape=(1,)), TensorType(float64, shape=(1000,)), TensorType(float64, shape=(1000,))]

HINT: Use a linker other than the C linker to print the inputs' shapes and strides.
HINT: Re-running with most PyTensor optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the PyTensor flag 'optimizer=fast_compile'. If that does not work, PyTensor optimizations can be disabled with 'optimizer=None'.
HINT: Use the PyTensor flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node.' could not be acquired.