markovmodel / PyEMMA

🚂 Python API for Emma's Markov Model Algorithms 🚂
http://pyemma.org
GNU Lesser General Public License v3.0
306 stars 119 forks source link

No return when using pyemma.msm.its #1576

Closed yingioi0 closed 1 year ago

yingioi0 commented 1 year ago

Hi, when I follow the jupyter notebook tutorials, I got no return after a very long time in estimating implied timescales from discrete trajectories at the section of MSM estimation and validation ( Case 2 ). Then I have to press ctrl + C and the trace back show below:

KeyboardInterrupt                         Traceback (most recent call last)
Cell In [6], line 1
----> 1 its = pyemma.msm.its(cluster.dtrajs, lags=[1, 2, 5, 10, 20, 50], nits=4, errors='bayes')

File ~/miniconda3/envs/pyemma/lib/python3.10/site-packages/pyemma/msm/api.py:253, in timescales_msm(dtrajs, lags, nits, reversible, connected, weights, errors, nsamples, n_jobs, show_progress, mincount_connectivity, only_timescales, core_set, milestoning_method)
    250 # go
    251 itsobj = _ImpliedTimescales(estimator, lags=lags, nits=nits, n_jobs=n_jobs,
    252                             show_progress=show_progress, only_timescales=only_timescales)
--> 253 itsobj.estimate(dtrajs)
    254 return itsobj

File ~/miniconda3/envs/pyemma/lib/python3.10/site-packages/pyemma/msm/estimators/implied_timescales.py:170, in ImpliedTimescales.estimate(self, X, **params)
    147 def estimate(self, X, **params):
    148     """
    149     Parameters
    150     ----------
   (...)
    168         how many subprocesses to start to estimate the models for each lag time.
    169     """
--> 170     return super(ImpliedTimescales, self).estimate(X, **params)

File ~/miniconda3/envs/pyemma/lib/python3.10/site-packages/pyemma/_base/estimator.py:418, in Estimator.estimate(self, X, **params)
    416 if params:
    417     self.set_params(**params)
--> 418 self._model = self._estimate(X)
    419 # ensure _estimate returned something
    420 assert self._model is not None

File ~/miniconda3/envs/pyemma/lib/python3.10/site-packages/pyemma/msm/estimators/implied_timescales.py:235, in ImpliedTimescales._estimate(self, dtrajs)
    233 with ctx:
    234     if not self.only_timescales:
--> 235         models, estimators = estimate_param_scan(self.estimator, dtrajs, param_sets, failfast=False,
    236                                                  return_estimators=True, n_jobs=self.n_jobs,
    237                                                  progress_reporter=pg, return_exceptions=True)
    238         self._estimators = estimators
    239     else:

File ~/miniconda3/envs/pyemma/lib/python3.10/site-packages/pyemma/_base/estimator.py:361, in estimate_param_scan(estimator, X, param_sets, evaluate, evaluate_args, failfast, return_estimators, n_jobs, progress_reporter, show_progress, return_exceptions)
    358     with closing(pool), ctx:
    359         res_async = [pool.apply_async(_estimate_param_scan_worker, a, callback=callback,
    360                                       error_callback=error_callback) for a in args]
--> 361         res = [x.get() for x in res_async]
    363 # if n_jobs=1 don't invoke the pool, but directly dispatch the iterator
    364 else:
    365     if logger_available:

File ~/miniconda3/envs/pyemma/lib/python3.10/site-packages/pyemma/_base/estimator.py:361, in <listcomp>(.0)
    358     with closing(pool), ctx:
    359         res_async = [pool.apply_async(_estimate_param_scan_worker, a, callback=callback,
    360                                       error_callback=error_callback) for a in args]
--> 361         res = [x.get() for x in res_async]
    363 # if n_jobs=1 don't invoke the pool, but directly dispatch the iterator
    364 else:
    365     if logger_available:

File ~/miniconda3/envs/pyemma/lib/python3.10/site-packages/multiprocess/pool.py:765, in ApplyResult.get(self, timeout)
    764 def get(self, timeout=None):
--> 765     self.wait(timeout)
    766     if not self.ready():
    767         raise TimeoutError

File ~/miniconda3/envs/pyemma/lib/python3.10/site-packages/multiprocess/pool.py:762, in ApplyResult.wait(self, timeout)
    761 def wait(self, timeout=None):
--> 762     self._event.wait(timeout)

File ~/miniconda3/envs/pyemma/lib/python3.10/threading.py:607, in Event.wait(self, timeout)
    605 signaled = self._flag
    606 if not signaled:
--> 607     signaled = self._cond.wait(timeout)
    608 return signaled

File ~/miniconda3/envs/pyemma/lib/python3.10/threading.py:320, in Condition.wait(self, timeout)
    318 try:    # restore state no matter what (e.g., KeyboardInterrupt)
    319     if timeout is None:
--> 320         waiter.acquire()
    321         gotit = True
    322     else:

KeyboardInterrupt: 

command history

The full command history is here ( I just copy it from html document): pdb = mdshare.fetch('alanine-dipeptide-nowater.pdb', working_directory='data') files = mdshare.fetch('alanine-dipeptide-*-250ns-nowater.xtc', working_directory='data') feat = pyemma.coordinates.featurizer(pdb) feat.add_backbone_torsions(periodic=False) data = pyemma.coordinates.load(files, features=feat) data_concatenated = np.concatenate(data) cluster = pyemma.coordinates.cluster_kmeans(data, k=200, max_iter=50, stride=10) its = pyemma.msm.its(cluster.dtrajs, lags=[1, 2, 5, 10, 20, 50], nits=4, errors='bayes')

environment list

My related environment list here ( I install PyEMMA via conda ): PyEMMA 2.5.12 numpy 1.23.3 pyemma 2.5.12 mdshare 0.4.2 scipy 1.9.1 IPython : 8.5.0 ipykernel : 6.15.3 ipywidgets : 7.7.2 jupyter_client : 7.3.5 jupyter_core : 4.11.1 jupyter_server : 1.18.1 jupyterlab : 3.4.7 nbclient : 0.6.8 nbconvert : 7.0.0 nbformat : 5.5.0 notebook : 6.4.12 qtconsole : 5.3.2 traitlets : 5.4.0 Python 3.10.6

Any one help me? Thank you!

thempel commented 1 year ago

Hi, does it work when you set n_jobs=1, i.e., pyemma.msm.its(cluster.dtrajs, lags=[1, 2, 5, 10, 20, 50], nits=4, errors='bayes', n_jobs=1)?

yingioi0 commented 1 year ago

Thanks a million! It works immediately. Now all goes well : )

thempel commented 1 year ago

You're welcome, happy to hear that it works :)