kutaslab / fitgrid

Multichannel event-related time-series regression modeling for EEG, MEG, and sensor array data
https://kutaslab.github.io/fitgrid
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

parallel lmer broke around 0.5.0.dev0 #179

Closed turbach closed 3 years ago

turbach commented 3 years ago

The problem ...

Diagnosis ...

First stab at an easy fix, so far so good ...

My next steps ...


MREs on local system, derived from the Actions CI

fitgrid at a53fbeee4 conda 4.9.2 and Python 3.6, 3.7, 3.8

conda build --python=3.8 -c defaults -c conda-forge -c ejolly conda conda create -n test_env_py3.8 fitgrid -c local -c defaults -c conda-forge -c ejolly conda activate test_env_py3.8 conda install pytest

# this succeeds and also with the import moved up to module scope
import fitgrid

def test_smoke_lmer_parallel():
    from pymer4 import Lmer

    epochs = fitgrid.generate(n_samples=2, n_channels=2)
    RHS = 'continuous + (continuous | categorical)'
    _ = fitgrid.lmer(epochs, RHS=RHS, parallel=True, n_cores=2)
# without from pymer4 import Lmer this fails
def test_smoke_lmer_parallel():
    epochs = fitgrid.generate(n_samples=2, n_channels=2)
    RHS = 'continuous + (continuous | categorical)'
    _ = fitgrid.lmer(epochs, RHS=RHS, parallel=True, n_cores=2)

Different error messages make one issue look like two ...

py 3.6, rpy2 3.3.6 py 3.7, rpy2 3.4.2

Error: C stack usage  210161152500 is too close to the limit
Error: C stack usage  210161152548 is too close to the limit
Error: C stack usage  210161152020 is too close to the limit
Fatal error: unable to initialize the JIT

py 3.8, rpy2 3.4.2

Exception in thread Thread-7:
Traceback (most recent call last):
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/multiprocessing/pool.py", line 470, in _handle_results
    task = get()
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/multiprocessing/connection.py", line 251, in recv
    return _ForkingPickler.loads(buf.getbuffer())
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/site-packages/pymer4/__init__.py", line 5, in <module>
    from .models import Lmer, Lm, Lm2
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/site-packages/pymer4/models/__init__.py", line 5, in <module>
    from .Lmer import Lmer
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/site-packages/pymer4/models/Lmer.py", line 9, in <module>
    from rpy2.robjects.packages import importr
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/site-packages/rpy2/robjects/__init__.py", line 19, in <module>
    from rpy2.robjects.robject import RObjectMixin, RObject
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/site-packages/rpy2/robjects/robject.py", line 10, in <module>
    rpy2.rinterface.initr_simple()
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/site-packages/rpy2/rinterface.py", line 859, in initr_simple
    _post_initr_setup()
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/site-packages/rpy2/rinterface.py", line 940, in _post_initr_setup
    signal.signal(signal.SIGINT, _sigint_handler)
  File "/home/turbach/miniconda3/envs/mkgpux_benchmark_py37/lib/python3.7/signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
turbach commented 3 years ago

Closed by 6eb1ae6d26fd613880ac6b81e0a367657ed5a9c4