pymc2 icon indicating copy to clipboard operation
pymc2 copied to clipboard

Sample function (MCMC) running AGONIZINGLY slowly

Open sarahvassall opened this issue 3 years ago • 2 comments

Hi, I built a hierarchical modal and am trying to run MCMC. I recently had a forced Windows update that is causing it to run at a snail's pace, with each sample taking ~2-3 seconds! I did not have this issue a few days ago, and I'm now running into this slowness in Jupyter Notebook and Lab, as well as Spyder. Currently using pymc36.

The model is m_vz_uni. Here is the code from the cell:

m_vz_uni.sample(8000,burn=2000,dbname='traces_vz_uni.db',db='pickle') stats_vz = m_vz_uni.gen_stats()

I've tried resetting kernels, reinstalling, restarting, etc. Nothing seems to fix it.

Thanks

sarahvassall avatar Feb 18 '21 00:02 sarahvassall

This might be better addressed on our Discourse page (https://discourse.pymc.io/) as it does not appear to be a specific bug report, but a few things to start with:

  • I assume you mean PyMC 3.6? That's a pretty old version--I strongly recommend updating to the newest release (3.11). You will have to update the call to sample when you update, as much has changed, particularly the DB backend. You should not need to pickle your output, as the sample should easily fit into memory.
  • If you are using NUTS for sampling (which should be the case if your model does not have any discrete unknown variables) you don't need 8000 samples to adequately characterize the posterior. Usually a thousand or so will do. If not, you probably need to boost the burnin (which is now called tune in more recent versions) instead.
  • The slowness could have something to do with your linear algebra libraries that might have been affected when you updated your operating system. Are there any messages when you import PyMC3?
  • One way to see if there is an issue with your system versus the model is to try and run your model on Google Colab; if it runs there then it is likely an issue with your setup.

fonnesbeck avatar Feb 22 '21 16:02 fonnesbeck

BTW, just noticed that you posted this in the old PyMC repo issue tracker and not the one for PyMC3. If you really are using PyMC version 2, then you definitely should update to PyMC3. I can help you port your model if you need assistance.

fonnesbeck avatar Feb 22 '21 17:02 fonnesbeck