.. include:: css.inc

.. _install_windows:


Windows Installation Instructions
#################################

.. warning::
    If you want to install the bleeding-edge or development version of Theano
    from GitHub, please make sure you are reading `the latest version of this
    page <http://deeplearning.net/software/theano_versions/dev/install_windows.html>`_.

.. |PlatformCompiler| replace:: ``python-dev``, ``g++`` >= 4.2
.. |CompilerName| replace:: ``g++``

.. comment: Requirements, optional requirements and installation of miniconda.
.. include:: requirements.inc
    :end-line: 58

Install requirements and optional packages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. note::

    * Arguments between <...> are optional.
    * ``m2w64-toolchain`` package provides a fully-compatible version of GCC and is then highly-recommended.

For Python 2*
:::::::::::::

.. code-block:: bash

    conda install numpy scipy mkl-service libpython <m2w64-toolchain> <nose> <nose-parameterized> <sphinx> <pydot-ng>

For Python 3*
:::::::::::::

.. code-block:: bash

    conda install numpy scipy mkl-service libpython <m2w64-toolchain> <nose> <nose-parameterized> <sphinx>

To install ``pydot`` (optional):

.. code-block:: bash

    pip install pydot-ng

.. _gpu_windows:

Install and configure the GPU drivers (recommended)
---------------------------------------------------

.. warning::

    OpenCL support is still minimal for now.

Install CUDA drivers
^^^^^^^^^^^^^^^^^^^^

Follow `this link <https://developer.nvidia.com/cuda-downloads>`__
to install the CUDA driver and the CUDA Toolkit.

You must reboot the computer after the driver installation.

Microsoft Visual C++ Compiler for Python 2.7 (optional)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you plan to compile libgpuarray and pygpu yourself, you will
need to install ``Microsoft Visual C++ Compiler for Python 2.7``.  It
provides the now-obsolete compilers form Visual Studio 2008 that are
required for compatibility with Python 2.7. To install the package for
all users please:

1. Download the installer for `Microsoft Visual C++ Compiler for Python 2.7
   <http://www.microsoft.com/en-us/download/details.aspx?id=44266>`_.
2. open an administrator's console (got to ``start``, then type ``cmd``,
   right-click on the command prompt icon and select ``run as administrator``)
3. ``cd`` to the directory when you downloaded the installer and execute ``msiexec /i
   VCForPython27.msi ALLUSERS=1`` . The package will be installed to ``C:\Program Files
   (x86)\Common Files\Microsoft\Visual C++ for Python\9.0``.
4. Download the ``stdint.h`` header from
   `here <https://sourceforge.net/p/mspgcc/msp430-libc/ci/master/tree/include/stdint.h>`_
   and save it as ``C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for
   Python\9.0\VC\include\stdint.h``.

When you are ready to compile libgpuarray, open a console (got to ``start``, type ``cmd`` and click
to the command prompt) and enter the following commands:

.. code-block:: none

   set VSFORPYTHON="C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0"

   REM for a 32 bit installation change this line to
   REM CALL %VSFORPYTHON%\vcvarsall.bat
   CALL %VSFORPYTHON%\vcvarsall.bat amd64


Installation of Theano and libgpuarray
======================================

Stable Installation
-------------------

With ``conda``
^^^^^^^^^^^^^^

If you use conda, you can directly install both theano and pygpu. Libgpuarray
will be automatically installed as a dependency.

.. code-block:: bash

    conda install theano pygpu

With ``pip``
^^^^^^^^^^^^

If you use pip, you have to install Theano and libgpuarray separately.

theano
::::::

.. comment: Installation instructions for theano for stable version.
.. include:: install_generic.inc
    :start-line: 11
    :end-line: 28

libgpuarray
:::::::::::

.. comment: Installation instructions (libgpuarray for stable version, then full bleeding-edge and developer version instructions).
.. include:: install_generic.inc
    :start-line: 32

Configure CUDA and libgpuarray after installation
=================================================

Cuda
----

To ensure Theano cand find CUDA headers and libraries, create an environment variable named ``CUDA_ROOT``
and set it to the CUDA directory. In a 64-bits computer, the CUDA directory should be something like
``C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0``.

To create permanently an environment variable, look for ``system environment variables``
in the Start search bar and then choose ``Set System Environment Variables`` (this works on Windows 8.1).

libgpuarray
-----------

[TODO]

Instructions for other Python distributions (not recommended)
=============================================================

If you plan to use Theano with other Python distributions, these are generic guidelines to get
a working environment:

    * Look for the mandatory requirements in the package manager's repositories of your distribution. Many
      distributions come with ``pip`` package manager which use `PyPI repository <https://pypi.python.org/pypi>`__.
      The required modules are Python (of course), NumPy, SciPy and a BLAS implementation (MKL or OpenBLAS).
      Use the versions recommended at the top of this documentation.
    * If the package manager provide a GCC compiler with the recommended version (see at top), install it. If not,
      you could use the build `TDM GCC <http://tdm-gcc.tdragon.net/>`_ which is provided for both 32- and 64-bit
      platforms. A few caveats to watch for during installation:

          1. Install to a directory without spaces (we have placed it in
             ``C:\SciSoft\TDM-GCC-64``)
          2. If you don't want to clutter your system PATH un-check ``add to
             path`` option.
          3. Enable OpenMP support by checking the option ``openmp support
             option``.

    * Install CUDA with the same instructions as above.
    * Install the latest, development version of libgpuarray following the
      `Step-by-step instructions <http://deeplearning.net/software/libgpuarray/installation.html#step-by-step-install>`__.
    * Configure libgpuarray with the same instructions as above.
