Installing Theano with GPU on Windows 64-bit

Theano is a numerical computation library for Python. It allows to use GPU for computation, and nicely fits for machine learning calculation, which is perhaps because Theano is primarily developed by a machine learning group at the University of Montreal.

I tried to install Theano to my Windows-powered machine to try GPU computations. And it was hard, as any UNIX software on Windows. To make it work these things should be set up:

 

Python 2.7

Use standard x64 installation from https://www.python.org/download/releases/2.7

MinGW 64

Instructions: http://ascend4.org/Setting_up_a_MinGW-w64_build_environment

NumPy

Can be installed using PIP: pip install numpy

SciPy

pip install scipy

CUDA

Get 64-bit version here: https://developer.nvidia.com/cuda-downloads

If installation fails – check event log, Windows might just need reboot.

PyCUDA

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycuda

Theano

I used ‘pip install Theano’, there are more ways to install, described here: http://deeplearning.net/software/theano/install.html

 

Then you need to configure .theanorc to use GPU:

http://deeplearning.net/software/theano/install.html (“Using the GPU” section)

Theano configuration details: http://deeplearning.net/software/theano/library/config.html

Test Theano GPU: http://deeplearning.net/software/theano/tutorial/using_gpu.html#using-gpu

 

Troubleshooting

Make sure that .theanorc is in the home directory of your shell. For my msys installation the home directory was msys/home/USERNAME.

 

If you get this error while using Theano:

nvcc : fatal error : Cannot find compiler ‘cl.exe’ in PATH

Add the line to the beginning of msys.bat:

call “c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat”

 

Useful links

CUDA installation: http://wiki.tiker.net/PyCuda/Installation/Windows

Theano installation: https://github.com/Theano/Theano/wiki/Windowsinstallation

Theano installation: http://machinomics.blogspot.com/2013/08/installing-theano-on-windows-64-bit.html