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

 

  • Pingback: Theano, Autoencoders and MNIST « triangleinequality

  • anaon

    Thanks for this, I was able to get theano working under windows 8.1 64. I had to install http://www.lfd.uci.edu/~gohlke/pythonlibs/#libpython to fix a library linker issue.

  • Charles

    Thanks for this guide. I also got Theano to work on my Win 7 x64 machine (finally) after quite a bit hassle. My suggestion (at the time being) is to get the bleeding-edge version using “pip install –upgrade –no-deps git+git://github.com/Theano/Theano.git” instead of simply installing with “pip install Theano”.

    I actually could not get Theano to work with the version obtained from “pip install Theano”, and there seemed to be small a bug in that version which gives me errors when trying to compile with Visual Studio 2012. That’s why I gave the bleeding-edge version a try, and it worked.

    As mentioned by the previous user, I believe libpython is needed too.

  • Anonymous

    could you please post contents of your nvcc.profile?

  • Zhengxing Chen

    Thanks man. Wrote a similar post based on yours: http://129.10.79.19/wordpress/?p=315

    • surmenok

      Welcome!

  • Cedric Oeldorf

    Hi! Thank you for your post. I’m running on windows 10 and have gotten to running theano on cpu. For some reason it doesn’t want to run on GPU. My .theanorc file looks as follows:

    [global]
    floatX = float32
    device = gpu

    [cuda]
    root=C:Program FilesNVIDIA GPU Computing ToolkitCUDAv7.5
    [nvcc]
    flags=-LC:UsersCedric=OeldorfAnaconda2libs
    compiler_bindir=C:Program Files (x86)Microsoft Visual Studio 12.0VCbin

    [blas]
    ldflags =
    #ldflags=-lopenblas # placeholder for openblas support

    Would you have any suggestions?

  • Shuokai Pan

    HI thank you for your post. I have the nvcc fatal error as you mentioned in the blog. But where I can find this ‘msys.bat’ file on windows 7?

    • surmenok

      Hi Shuokai,
      On my machine it is here: c:MinGWmsysmsys.bat