Thursday, 14 April 2016

Installing pymc3 on Windows machines

PyMC3 is a python package for estimating statistical models in python. The package has an API which makes it very easy to create the model you want (because it stays close to the way you would write it in standard mathematical notation), and it also includes fast algorithms that estimate the parameters in the models (such as NUTS).  All in all it is a great package, BUT there is one significant problem: It seems very difficult to install pymc3 with the dependencies that are needed to make it run reasonable fast. This is partly because pymc3 requires Theano which is a package that speeds up computations, and this package in turn speeds up computations even more if it can use the GPU instead of the CPU, but making this happen often requires some extra installations. After fiddling around for some hours, I finally ended up with the following recipe for installing something that worked reasonably fast (but it does not use the GPU):

1. Install Anaconda 2.7 (64 bit) from Continum: https://www.continuum.io/downloads

2 If you do not have github installed, install it.
Easy setup here: https://desktop.github.com/
More detailed instructions here: https://help.github.com/articles/set-up-git/


3. Then open the anaconda terminal from the start menu (make sure it is the Python 2 version if you have several versions) and run the following:

conda install mingw libpython

pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git

pip install git+https://github.com/pymc-devs/pymc3


If you get an error about not finding "git", you need to add git to the path: Instructions here: http://stackoverflow.com/questions/26620312/installing-git-in-path-with-github-client-for-windows



6 comments:

  1. Thanks a lot! could not get it installed before!

    ReplyDelete
  2. Many thanks :)
    It worked flawlessly

    ReplyDelete
  3. This is great. Note that it's even easier now that pymc3 is available as a conda-package on conda-forge:

    conda install -c conda-forge pymc3

    ReplyDelete
  4. After installing Git Hub, open the application and log in. Click on the settings icon in the upper right corner and go to options. Set Cmd as the default shell and click save. Now go to my computer, advanced settings, edit environment variables and paste in the location of your git as done here: http://stackoverflow.com/questions/26620312/installing-git-in-path-with-github-client-for-windows
    If you don't set the default shell to cmd, it will not work.

    ReplyDelete
  5. ** Installation of pymc3 with python 3.6 for windows 10 **

    I've had serious problems to find an installation that makes pymc3 work properly. With "import pymc3" I've got a fatal error usually. According to the many blog contributions - which I tested all.... - it does seem to be a procedure not completely stable yet. BUT: based on the Anaconda distribution the follwing did work for me (for Jupyter also):

    (see also: http://deeplearning.net/software/theano/install_windows.html)

    1. conda install theano
    2. conda install pygpu
    3. pip install pymc3 (pip necessary when using python 3.6)

    ReplyDelete