GilLabs { GilLabs }

How to Install Theano, Blocks and Fuel

10 Jan 2016
PT FR

The very first step to develop a Deep Learning experiment - if you don’t want to code everything from scratch - is to look for a proper 3rd party component that provides a straightforward interface and a great performance.

In python, there are a lot of frameworks and libraries to work with Deep Learning. After I had participated in a course taught by Laurent Dihn from University of Montreal, I was introduced to the combined toolkit of Theano, Blocks and Fuel.

Theano is a very known mathematical python library used for deep learning. This library contains a lot of useful methods to simplify model generation like using derivative of symbolic functions. Due to its bindings with PyCuda, Theano allows to use the same code to evaluate on CPU or GPU only by changing a flag.

Blocks is a set of utilitary scripts that easen some tasks on Theano, like model generation, load and training data, and visualizing results.

Fuel is data processing library that handles some neat things like download and parse image datasets into numpy arrays. One of its advantage is a same interface that can handle a lot different types of data.

Installing on Windows

I found some useful tips on this reddit post and I have tested it on Windows 8.1 and Windows 10.

The first step is download and install the Windows version of Anaconda. After a simple installation wizard, we need to install the required libraries for Theano. Thanks to Anaconda, we can use a very simple command-line tool conda in the Anaconda Prompt:

    conda install pip six nose numpy scipy graphviz
    conda install mingw libpython

Some necessary python libraries are pre-requisite to specific Theano functions, like drawing debug graphs of operation nodes, and can also be used in Blocks or Fuel.

    pip install pydot2 progressbar2 picklable-itertools

Theano can be installed using pip:

    pip install theano

Fuel can be downloaded directly from github repository: https://github.com/mila-udem/fuel. In order to install it, we need to run the script setup.py:

    cd fuel
    python setup.py install

Fuel can be downloaded directly from github repository: https://github.com/mila-udem/blocks. In order to install it, we need to use python to execute the setuptools script setup.py

    cd blocks
    python setup.py install

Testing Theano on Anaconda Prompt

Installing on OSX

According to Theano page about mac installation we can download Anaconda and then Theano can be installed by pip:

    conda install pip six nose numpy scipy graphviz
    pip install pydot2
    pip install Theano

After downloading Fuel on github page, inside its folder there is a script setup.py that handles the installation by means of setuptools:

    cd fuel
    python setup.py install

Once downloaded Blocks from github page, you can install it by executing the setuptools script setup.py:

    cd blocks
    python setup.py install

Theano on Mac Terminal

Installing on Ubuntu

Some installation steps are published on Theano site, so by following it I easily managed to install it on Ubuntu 14.10.

Download and e install all requisites of the libraries using apt-get:

    sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git gfortran libhdf5-dev graphviz

Then Theano can be installed by pip:

    pip install Theano

Fuel library can be also installed using pip directly from github repository:

    pip install git+git://github.com/mila-udem/fuel.git 

Blocks library also is installed by pip:

    pip install git+git://github.com/mila-udem/blocks.git

Running Theano on Ubuntu

Installing a Python IDE

After some good experiences using PyDev and Eclipse, I recomend this light version Liclipse: http://www.liclipse.com/download.html. Some other good options can be found in: http://pedrokroger.net/choosing-best-python-ide/.

LiClipse IDE