Skip to content

Theano Installation

luongthevinh edited this page Jan 27, 2016 · 13 revisions

Theano is a Python library that enables using a compatible GPU (Graphical Processing Unit) of the computer for numerical computation, which is far superior in performance terms to computation by the computer’s CPU (Central Processing Unit).

  • Currently, the most, if not only, effectively Theano-supported GPUs are those by NVIDIA;
  • Even if your machine do not have an NVIDIA graphics card, Theano is still useful in compiling complex calculations down to highly efficient C / C++ or machine code that can execute very fast.  Because of its huge performance-boosting benefits, Theano is prominent in extremely data-intensive, large-scale Machine Learning applications such as those in cutting-edge Neural Networks-based Deep Learning.

Having said that, Theano is still very young ("young" = nice word for "buggy") and its setup, configuration and usage demand a high degree of risk-taking and perseverance. :( (It helps if you are good with your friends and hence enjoy good karma)

Theano Installation and Configuration on Mac

You may refer to the Theano installation and configuration guide for Mac here.

Appropriate steps vary from machine to machine. Consult Dr. Google and Prof. Stack Overflow whenever you get stuck. In our own experience, the recommended key steps include:

  1. Install the Anaconda Python v2.7 distribution;

  2. Install the CLang compiler through installing the XCode app VERSION 6.2 from the Apple Developer site and running XCode once to install its command-line tools;

    • if you have Xcode version >6.2, uninstall / delete it and install v6.2;
    • copy the app to the /Applications folder and rename it "Xcode_6.2.app";
  3. Install the CUDA graphics driver and toolkit v7.5 from NDIVIA in order to use the GPU to perform numerical computation;

    • CUDA Toolkit installation manual here;
    • add the following to the .bash_profile file in your home folder:
      • export PATH=/Developer/NVIDIA/CUDA-7.5/bin:$PATH
      • export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-7.5/lib:$DYLD_LIBRARY_PATH
  4. Download this template .theanorc file for Mac to the /Users/<Your-Username-On-Your-Mac-Machine>/ home folder, and customize it where necessary

  5. Restart your machine for changes to take effect

Theano Installation and Configuration on Windows

You may refer to the Theano installation and configuration guide for Windows here.

Appropriate steps vary from machine to machine. Consult Dr. Google and Prof. Stack Overflow whenever you get stuck. In our own experience, the recommended key steps include:

  1. Install the Anaconda Python v2.7 distribution;

  2. Install the MinGW and LibPython Python packages by running the following command in a command-line terminal window: conda install MinGW LibPython

  3. Find and install Visual Studio Community 2013; _ do NOT install the 2015 version, which is not compatible with the CUDA software below;

  4. Install the CUDA graphics driver and toolkit v7.5 from NDIVIA in order to use the GPU to perform numerical computation;

  5. Install a GNU C Compiler (GCC) package such as TMD-GCC, appropriate for your Windows machine's processor (32-bit / 64-bit);

  6. Download this template .theanorc file for Mac to the C:/Users/<Your-Username-On-Your-Windows-Machine>/ home folder, and customize it where necessary 

Verification Step

Download this TheanoTestScript.py file to your computer and run it with command python TheanoTestScript.py in the corresponding folder.

Verify that it completes successfully, giving your a comparison of speeds between NumPy and Theano:

  • if your machine does not have a compatible GPU, the two speeds should be similar
  • if your machine does have a compatible GPU, for this small test, the Theano time may be slower than the NumPy time because of data transfer overhead from and to the GPU; Theano saves time for much larger operations 
Clone this wiki locally