Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7dc5cf52
提交
7dc5cf52
authored
2月 26, 2015
作者:
carriepl
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2534 from ballasn/win_install
Windows documentation
上级
0fe5fdb1
e09215fb
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
616 行增加
和
560 行删除
+616
-560
install.txt
doc/install.txt
+10
-560
install_windows.txt
doc/install_windows.txt
+605
-0
nvcc_compiler.py
theano/sandbox/cuda/nvcc_compiler.py
+1
-0
没有找到文件。
doc/install.txt
浏览文件 @
7dc5cf52
...
@@ -799,374 +799,8 @@ note that you must first register to it, by going to `theano-users`_).
...
@@ -799,374 +799,8 @@ note that you must first register to it, by going to `theano-users`_).
Windows
Windows
-------
-------
Installing Dependencies
:ref:`install_windows` provides step-by-step instructions on how to install Theano on 32- or 64-bit Windows systems, using freely available
~~~~~~~~~~~~~~~~~~~~~~~
tools and compilers.
.. note::
Command lines listed below are assumed to be run in a Windows prompt:
click ``Start`` and type the ``cmd`` command to launch a command window.
In academia: EPD
################
If you are working in academia, the easiest way to install most of the
dependencies is to install `Enthought Python Distribution (EPD) <http://enthought.com/products/epd.php>`_.
If you are affiliated with a university (as student or employee), you can
download the installation for free.
EPD installation includes in particular Python (and the development headers),
NumPy, SciPy, nose, sphinx, easy_install, pydot (but *not* `Graphviz`_, which is
necessary for it to work), g++, and the MKL
implementation of blas.
If you want to use the iPython shell, you should first try to import NumPy
in it::
C:\Users\user>ipython
[...]
In [1]: import numpy
If you see an error message telling you that ``DLL load failed``, that is
probably due to a bug in the script launching ipython. If ``C:\Python27``
is the directory where you installed EPD, edit
``C:\Python27\Scripts\ipython.bat``, there should be a line saying::
set path="C:\Python27";%path%
Remove the quotes around ``Python27``, leading to::
set path=C:\Python27;%path%
Then, it should work in all new terminals.
pip is not included in EPD, but you can simply install it with::
easy_install pip
You can then proceed to the :ref:`windows_basic` or the :ref:`windows_bleeding_edge`.
Alternative: Canopy
###################
Another software from Enthought that installs all Theano dependencies.
If you are affiliated with a university (as student or employee), you
can download the installation for free.
- Install Canopy x64, and update it to the latest version (`Help /
Software updates...`), as older Canopy versions have trouble installing
`pip`.
- Then install `pip` from Canopy Package Manager.
- In the Windows shell (type `cmd` in the Windows start menu to bring it up),
type `pip install theano`.
- In Canopy Package Manager, search and install packages "mingw 4.5.2" and "libpython 1.2"
- (Needed only for Theano 0.6rc3 or earlier)
The "libpython 1.2" package installs files `libpython27.a` and `libmsvcr90.a` to
`C:\\Users\\<USER>\\AppData\\Local\\Enthought\\Canopy\\User\\libs`. Copy the two files to
`C:\\Users\\<USER>\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\libs`.
- (Needed only for Theano 0.6rc3 or earlier) Set the Theano flags
``blas.ldflags=-LC:\Users\<USER>\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\Scripts -lmk2_core -lmk2_intel_thread -lmk2_rt``.
Alternative: AnacondaCE
#######################
ContinuumIO_ is providing a free Python distribution for Windows (32-bit
and 64-bit), including all dependencies of Theano. If you are not
eligible for a download of EPD or Canopy (via a commercial, or free academic
licence), this is the easiest way to install
Theano's dependencies. Simply download and execute the installer from
`AnacondaCE downlowad page <http://continuum.io/anacondace.html>`__,
then download and execute the :ref:`windows_anaconda`.
.. _ContinuumIO: http://continuum.io
Alternative: Python(x,y)
########################
If you do not have a commercial licence of EPD, and are not eligible to a free
academic licence, and neither
Python nor MinGW is installed on your computer, you can install most
dependencies of Theano with `Python(x,y) <http://www.pythonxy.com>`__.
It is a single installation
file that contains additional packages like NumPy, SciPy, IPython, Matplotlib,
MinGW, Nose, etc.
Note however that there is no 64 bit version currently available.
You can keep the default install options, except that the installation
directory should not contain any blank space (in particular, do not install it
into ``C:\Program Files``).
Alternative: manual installation
################################
The following instructions provide steps for manual installation of all Theano
dependencies.
Note that it should be
possible to run Theano with `Cygwin <http://www.cygwin.com/>`__ instead of
MinGW, but this has not been tested yet.
- For 32 bit MinGW: from `the MinGW files <http://sourceforge.net/projects/mingw/files/>`__,
download the latest version of the ``Automated MinGW Installer``
(``mingw-get-inst``) and install it (you should install all optional components,
except the Objective C and Ada compilers which are not needed).
- For 64 bit MinGW (**note that manual installation for 64 bit is experimental**):
download the latest version of MinGW-w64 from the project's
`releases page <http://sourceforge.net/projects/mingw-w64/files/>`__, and extract
it for instance to ``C:\mingw64``. Also download MSYS from
`this page <http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/>`__
(although it is a 32-bit version of MSYS, this does not matter since it is only
a convenience tool). Extract MSYS into the same folder, so that for instance you
end up with ``C:\mingw64\msys``. Run ``C:\mingw64\msys\msys.bat`` and in the MSYS
shell, type
.. code-block:: bash
sh /postinstall/pi.sh
and answer the few questions so that MSYS is properly linked to your MinGW install.
- It is recommended to set your MSYS home to be the same as your Windows home
directory. This will avoid inconsistent behavior between running Theano
in a Windows command prompt vs. a MSYS shell. One way to do this without
setting a global Windows ``HOME`` environment variable (which may affect
other programs) is to edit your ``msys.bat`` file (found e.g. under
``C:\MinGW\msys\1.0`` or ``C:\mingw64\msys``) and add the following line at
the beginning (note that you may need to use e.g. Wordpad to edit this file,
since Notepad gets confused by Unix-style line breaks):
.. code-block:: bash
set HOME=%USERPROFILE%
- If you do not have them already, install the latest versions of
`Python 2.x <http://www.python.org/download/windows>`__ and
corresponding `NumPy <http://sourceforge.net/projects/numpy/files/>`__
then `SciPy <http://sourceforge.net/projects/scipy/files/>`__
packages (simply use the executable installers).
Note that there are currently no official 64 bit releases of NumPy and
SciPy, but you can find unofficial builds
`here <http://www.lfd.uci.edu/~gohlke/pythonlibs/>`__.
- Ensure that the Python installation directory and its ``Scripts``
sub-directory are in your system path. This may be done by
modifying the global ``PATH`` Windows environment variables, or by creating
a ``.profile`` file in your MinGW home, containing a line like
``export PATH=$PATH:/c/Python27:/c/Python27/Scripts`` (note that the latter
will work only when you run Theano from an MSYS shell).
- If you are installing the 64 bit version, you will need the following hack
to be able to compile Theano files with GCC (skip this step if you are using
the 32 bit version). In a temporary work directory, copy ``python27.dll``
(found in ``C:\\Windows\\System32``) as well as
`python27.def <http://wiki.cython.org/InstallingOnWindows?action=AttachFile&do=get&target=python27.def>`__.
Edit ``python27.def`` and replace ``Py_InitModule4`` with ``Py_InitModule4_64``.
Then open an MSYS shell, go to this temporary directory, and run:
.. code-block:: bash
dlltool --dllname python27.dll --def python27.def --output-lib libpython27.a
Finally, copy the libpython27.a file that was generated into your
``C:\\Python27\\libs`` folder.
- In order to run Theano's test-suite, you will need `nose
<http://somethingaboutorange.com/mrl/projects/nose>`__.
After unpacking its source code (you may use `7-zip
<http://www.7-zip.org/>`__), you can build and install it from within
its code directory by running the following command (either from a Windows
command prompt or an MSYS shell):
.. code-block:: bash
python setup.py install
At this point, whether you installed Python(x,y) or individual components, you
should have MinGW, Python, Numpy, SciPy and Nose installed.
Installing Theano
~~~~~~~~~~~~~~~~~
Once the dependencies are installed, you can download and install
Theano. The easiest way is to install the latest released version
(see :ref:`windows_basic`). However, if you want to get the latest
development version, or edit the code, you should follow the
instructions in :ref:`windows_bleeding_edge`.
.. _windows_anaconda:
Windows installer for AnacondaCE
################################
.. note::
This don't work with current Anaconda. Help needed to repair this.
If you installed AnacondaCE, the simplest way to install and configure
Theano is to download and execute this `Windows installer
for Theano on AnacondaCE for Windows
<https://github.com/Theano/Theano-wininstaller/raw/master/bin/theano_installer_latest.msi>`__.
.. note::
It is possible that you need to logout/login or restart the
computer after installing AnacondaCE and before running Theano
installer. Otherwise, sometimes the Theano installer while trying
to find pip.
.. note::
This installer was tested on Windows 7, 64-bit edition, and AnacondaCE
version 1.3.1. Please get back to us if you experience trouble with it.
This installer will:
- Copy MinGW runtime DLLs into ``C:\\Anaconda\\``, so they are in the ``PATH``;
- Call ``pip install theano``, installing the latest released version;
- Set up a default configuration file for Theano,
``theanorc_default.txt``, and set it up as your ``.theanorc.txt`` if it
does not exist. It contains:
.. code-block:: cfg
[global]
openmp=False
[blas]
ldflags=
When uninstalling, it will call ``pip uninstall Theano``, and remove the
compilation cache as well as ``theanorc_default.txt``.
.. _windows_basic:
Basic user installation
#######################
The easiest way to obtain the released version of Theano is from PyPI using
pip_ by typing, in a Windows command prompt:
.. code-block:: bash
pip install Theano
.. _windows_bleeding_edge:
Bleeding-edge installation
##########################
We describe
here instructions to use the latest code repository version (bleeding-edge).
Command lines listed below are assumed to be run in a Windows prompt
(click ``Start`` and type the ``cmd`` command), and may need to be adapted if
used within an MSYS Shell (not available if you only installed Python(x,y)).
- The first option is to navigate to the
`Theano GitHub page <http://github.com/Theano/Theano>`__ and click the ``ZIP``
button in the top-left corner to download a zip file with the latest
development version. Unzip this file where you want Theano to be
installed, then rename the unzipped folder to ``Theano``.
- The second option is to use Git, which you can get
`here <http://git-scm.com/download>`__: download the latest version of the
"Full installer for official Git" from the ``msysgit`` download page.
We recommend that you select the following options:
"Run Git from the Windows Command Prompt" / 'Use Git Bash only",
then "Checkout as is, commit Unix-style endings".
Navigate into the directory you want Theano to be installed in, and download
it with
.. code-block:: bash
git clone git://github.com/Theano/Theano.git
- Add (or edit) the ``PYTHONPATH`` environment variable (into Control
Panel / System / Advanced / Environment Variables), so that it contains
the full installation directory of Theano. Restart a prompt to verify
that it works (the example below assumes you installed Theano into your
home directory):
.. code-block:: none
C:\Users\login>echo %PYTHONPATH%
C:\Users\login\Theano
Configure Theano
################
If you installed Python through EPD, or through the installation script for
Anaconda, you should be all set by now. Otherwise,
whether you installed Theano through pip or git, you should follow these
steps.
- Create a new ``.theanorc`` text file (or ``.theanorc.txt``, whichever is easier
for you to create under Windows) in your user profile directory (the directory you
are into when you start a new command prompt with ``cmd``), containing the
following two lines:
.. code-block:: cfg
[blas]
ldflags =
You do not need to do the following now, because it is not usually needed, but if
later on, when running Theano, you see an error message that looks like:
*error: 'assert' was not declared in this scope*
then you will have to add another section:
.. code-block:: cfg
[gcc]
cxxflags = -IC:\MinGW\include
- You are now ready to run Theano.
It will use NumPy for dot products, which is still pretty fast (see below for
optional instructions on how to compile your own BLAS library).
To test that Theano correctly reads your configuration file, run Python
(e.g. by just typing ``python`` in a prompt) and run the following code:
.. code-block:: python
import theano
print theano.config.blas.ldflags
This should print the same content as in your config file, i.e. nothing
(if your config file was not read properly, it would print '-lblas', and
trying to compile any Theano function would result in a compilation error
due to the system being unable to find 'blas.dll').
Testing your installation
~~~~~~~~~~~~~~~~~~~~~~~~~
Currently, due to memory fragmentation issue in Windows, the
test-suite breaks at some point when using ``theano-nose``, with many error
messages looking
like: ``DLL load failed: Not enough storage is available to process this
command``. As a workaround, you can instead run:
.. code-block:: bash
theano-nose --batch
This will run tests in batches of 100, which should avoid memory errors.
Note that this script calls ``nosetests``, which may require being run from
within an MSYS shell if you installed Nose manually as described above.
.. note::
In Theano versions <= 0.5, ``theano-nose`` was not included. If you
are working with such a version, you can call this command instead:
.. code-block:: bash
python theano/tests/run_tests_in_batch.py
Editing code in Visual Studio
Editing code in Visual Studio
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
@@ -1179,200 +813,16 @@ Also, be aware that it will not make Theano use Visual Studio to compile C
...
@@ -1179,200 +813,16 @@ Also, be aware that it will not make Theano use Visual Studio to compile C
files: it is only meant to provide an easy way to edit Theano code within
files: it is only meant to provide an easy way to edit Theano code within
the Visual Studio editor.
the Visual Studio editor.
Compiling a faster BLAS
~~~~~~~~~~~~~~~~~~~~~~~
If you installed Python through EPD, Theano will automatically link with the
MKL library included in EPD, so you should not need to compile your own BLAS.
.. note::
The instructions below have not been tested in a Windows 64 bit environment.
If you want a faster and/or multi-threaded BLAS library, you can
compile OpenBLAS (ATLAS may work too, but was not tested, and is
usually reported to be slower and more difficult to compile -- especially
on Windows).
OpenBLAS can be downloaded as a zip file from
`its website <http://xianyi.github.io/OpenBLAS/>`__
(we tested v0.2.6).
To compile it, you will also need MSYS and wget (installation steps are
described below).
If you already have a full install of MinGW, you should
have MSYS included in it, and thus should be able to start a MinGW shell.
If that is the case, you can skip the following MSYS installation steps.
Note that these steps were written for Python(x,y), but should also work
for other bundle Python distributions like EPD (changing paths accordingly,
for instance in EPD 7.3.2 the MinGW folder is
``EPD7.3.2\EGG-INFO\mingw\usr\i686-w64-mingw32``).
To install MSYS on top of the MinGW installation included within Python(x,y),
do as follows:
- Download the `mingw-get command-line installer binary
<http://sourceforge.net/projects/mingw/files/Installer/mingw-get/>`__.
- Unpack its content into your ``pythonxy\mingw`` directory.
- In a prompt (``cmd``), install MSYS with
.. code-block:: bash
mingw-get install msys-base
If ``mingw-get`` cannot be found automatically, just navigate first into the
folder were it was extracted (it is found in the ``bin`` subfolder).
- Edit ``pythonxy\mingw\msys\1.0\msys.bat`` (e.g. in Wordpad) and add as first
line ``set HOME=%USERPROFILE%``. Then create an easily accessible shortcut
(e.g. on your desktop) to this file, run it and within the MSYS
console, run the MSYS post-install script:
.. code-block:: bash
/postinstall/pi.sh
It will ask for your MinGW installation directory (e.g.
``c:/pythonxy/mingw``; note the forward slashes).
Once you have a working MinGW/MSYS shell environment, you can go on as
follows:
a) Install ``wget`` by running the setup program you can download on the
Windows Installation References
`wget website <http://gnuwin32.sourceforge.net/packages/wget.htm>`__.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that this setup does not add ``wget`` into the system PATH, so you
will need to modify the ``PATH`` environment variable accordingly (either in
Windows or in a ``.profile`` startup file in your MinGW home). Once this is done,
type ``wget --version`` in a MinGW shell to verify that it is working
properly. Note also that if you are behind a proxy, you should set up your
``HTTP_PROXY`` environment variable, or use a custom ``wgetrc`` config file
for wget to be able to download files.
b) Unzip OpenBLAS and, in a MinGW shell, go into the corresponding directory.
c) Compile OpenBLAS with:
.. code-block:: bash
quickbuild.win32 1>log.txt 2>err.txt
(use ``quickbuild.win64`` for 64-bit Windows).
Compilation can take a while, so now is a good time to take a break.
When it is done, you should have ``libopenblas.dll`` in your OpenBLAS
folder. If that is not the case, check the ``err.txt`` log for build errors.
d) Make sure that ``libopenblas.dll`` is in a folder that is in your ``PATH``.
e) Modify your .theanorc (or .theanorc.txt) with
``ldflags = -LX:\\YYY\\ZZZ -lopenblas`` where ``X:\\YYY\\ZZZ`` is the path
to the folder containing ``libopenblas.dll``.
This setting can also be changed in Python for testing purpose (in which
case it will remain only for the duration of your Python session):
.. code-block:: python
theano.config.blas.ldflags = "-LX:\\YYY\\YYY -lopenblas"
f) To test the BLAS performance, you can run the script
``theano/misc/check_blas.py``.
Note that you may control the number of threads used by OpenBLAS with
the ``OPENBLAS_NUM_THREADS`` environment variable (default behavior is to use
all available cores).
Here are some performance results on an Intel Core2 Duo 1.86 GHz,
compared to using Numpy's BLAS or the un-optimized standard BLAS
(compiled manually from its source code).
Note that we report here results for GotoBLAS2 which is the ancestor of
OpenBLAS (this benchmark still needs to be updated with OpenBLAS results):
* GotoBLAS2 (2 threads): 16s
* NumPy (1 thread): 48s
* Standard BLAS (un-optimized, 1 thread): 166s
Conclusions:
* The unoptimized standard BLAS is very slow and should not be used.
* The Windows binaries of NumPy were compiled with ATLAS and are surprisingly fast.
* GotoBLAS2 is even faster, in particular if you can use multiple cores.
.. note::
If you get a ``DLL load failed`` error message, it typically means that
a required DLL was not found in the PATH. If it happens only when you are
using OpenBLAS, it means it is either ``libopenblas.dll`` itself or one of its
dependencies. In the case where it is a dependency, you can use the
`Dependency Walker <http://www.dependencywalker.com/>`__ utility to figure out
which one.
.. _gpu_windows:
Using the GPU
~~~~~~~~~~~~~
Currently, GPU support under Windows is still in an experimental state.
The following instructions should allow you to run GPU-enabled Theano code
only within a Visual Studio command prompt.
Those are instructions for the 32-bit version of Python (the one that comes
with Python(x,y) is 32-bit).
Blanks or non ASCII characters are not always supported in paths. Python supports
them, but nvcc may not (for instance version 3.1 does not).
It is thus suggested to manually define a compilation directory without such
characters, by adding to your Theano configuration file:
.. code-block:: cfg
[global]
base_compiledir=path_to_a_directory_without_such_characters
Then
1) From the CUDA downloads page, download and install:
a. The Developer Drivers (32-bit on 32-bit Windows, 64-bit on 64-bit
Windows).
b. The CUDA Toolkit (32-bit even if your Windows is 64-bit, as it must
match your Python installation).
c. The GPU Computing SDK (32-bit as well).
2) Test some pre-compiled examples of the SDK.
3) Install Visual C++ (you can find free versions by looking for "Visual
Studio Express").
4) Follow instructions from the "CUDA Getting Started Guide" available on
the NVidia website to compile CUDA code with Visual C++. If that does not
work, you will probably not be able to compile GPU code with Theano.
5) Edit your Theano configuration file to add lines like the following
(make sure these paths match your own specific versions of Python and
Visual Studio):
.. code-block:: cfg
[nvcc]
flags=-LC:\Python26\libs
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
6) Start a Visual Studio command prompt (found under the "Visual Studio
Tools" programs folder).
In Python do: ``import theano.sandbox.cuda``. This will compile the
first CUDA file, and no error should occur.
7) To test a simple GPU computation, first set up Theano to use the GPU
by editing your configuration file:
.. code-block:: cfg
[global]
device = gpu
floatX = float32
Then run the ``theano/misc/check_blas.py`` test file.
You can also find additional test code and useful GPU tips on the
1. http://stackoverflow.com/questions/9047072/windows-python-version-and-vc-redistributable-version
:ref:`using_gpu` page.
2. http://stackoverflow.com/questions/1865069/how-to-compile-a-64-bit-application-using-visual-c-2010-express
3. http://blog.victorjabur.com/2011/06/05/compiling-python-2-7-modules-on-windows-32-and-64-using-msvc-2008-express/
4. http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio
5. http://stackoverflow.com/questions/11182765/how-can-i-build-my-c-extensions-with-mingw-w64-in-python
6. https://mail.python.org/pipermail/python-announce-list/2014-September/010457.html
Generating the documentation
Generating the documentation
...
...
doc/install_windows.txt
0 → 100644
浏览文件 @
7dc5cf52
.. _install_windows:
Installation of Theano on Windows
==================================
These instructions show step-by-step how to install Theano and
required dependencies on a 32- or 64-bit system using freely available
tools and compilers.
Installing Dependencies
~~~~~~~~~~~~~~~~~~~~~~~
.. note::
Command lines listed below are assumed to be run in a Windows prompt:
To open the prompt on Windows <= 7, click ``Start`` and type the ``cmd`` command to launch a command window.
In Windows 8, go to the Start screen and type ``command`` or ``cmd``.
Theano currently works on Windows, however it requires compilers for
C/C++ (for Python 2.7 family this has to be Microsoft Visual Studio
2008 compiler), CUDA (CUDA v5.5 is required as it is the latest
version supporting Visual Studio 2008), and GCC (for non-CUDA C code
generated by Theano).
Visual Studio and CUDA
######################
Unfortunately Microsoft recently stopped distributing Visual Studio
Express 2008 (the compilers required for Python 2.7 are provided,
though), therefore we require a temporary install of Visual Studio Express
2010 to be able to install CUDA (its installer requires a Visual
Studio installation to proceed). Afterwards, the Visual Studio 2010
can be safely removed. If someone knows how to install CUDA 5.5
without a proper Visual Studio installation, please let us know.
First we need to install Microsoft Visual Studio 2010 Express, which
is required to install CUDA. You can download it from
`Visual Studio Express
<http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx>`_.
Please install the Visual C version. We have downloaded the
`all-in-one CD <http://go.microsoft.com/?linkid=9709969>`_, extracted
it using `7zip <http://www.7-zip.org/>`_, and ran the installer at
VCExpress\\setup.exe.
If you want a 64bit Python installation, Visual Studio 2010 Express
doesn't provide a 64bit compiler. To get one download and install the
`Windows Software Development Kit version 7.1
<http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx>`_.
Now you have a running (and free even for commercial use) installation
of MSVS2010 IDE with 32- and 64-bit compilers.
Once Visual Studio is installed, you can install CUDA. We recommend
CUDA 5.5, as it supports MSVC 2008. Download the CUDA installer from
`the CUDA archive
<https://developer.nvidia.com/cuda-toolkit-55-archive>`_. Be sure to
get 32-, or 64-bit version depending on your system configuration.
Once CUDA is installed you can remove VisualStudio Express 2010.
Finally, grab the `Microsoft Visual C++ Compiler for Python 2.7
<http://www.microsoft.com/en-us/download/details.aspx?id=44266>`_. 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. open an administrator's console (got to ``start``, then type ``cmd``,
right-click on the command prompt icon and select ``run as
administrator``)
2. ``cd`` to your downloads directory 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``.
Finally download the ``stdint.h`` header from
`here <ttp://msinttypes.googlecode.com/svn/trunk/stdint.h>`_ and save it as
``C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for
Python\9.0\VC\include\stdint.h``.
GCC
###
Theano C code compiler currently requires a GCC installation. We have
used 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``.
Scientific Python distribution
##############################
We highly recommend the Pierre Raybaut's `WinPython
<http://winpython.sourceforge.net/>`_ distribution - it is compiled
for both 32- and 64-bit systems, links against the fast `MKL
<https://software.intel.com/en-us/intel-mkl>`_ BLAS
implementation, supports installation of auxiliary packages from
`Chris Gohlke <http://www.lfd.uci.edu/~gohlke/pythonlibs/>`_ and is
free.
WinPython also allows for a portable installation and doesn't clutter
your main system PATH. We have installed it to
``c:\SciSoft\WinPython-64bit-2.7.6.4``.
Alternative in academia: EPD
++++++++++++++++++++++++++++
If you are working in academia, an easy way to install most of the
dependencies is to install `Enthought Python Distribution (EPD) <http://enthought.com/products/epd.php>`_.
If you are affiliated with a university (as student or employee), you can
download the installation for free.
EPD installation includes, in particular, Python (and the development headers),
NumPy, SciPy, nose, sphinx, easy_install, pydot (but *not* `Graphviz`_, which is
necessary for it to work), g++, and the MKL
implementation of blas.
If you want to use the iPython shell, you should first try to import NumPy
in it::
C:\Users\user>ipython
[...]
In [1]: import numpy
If you see an error message telling you that ``DLL load failed``, that is
probably due to a bug in the script launching ipython. If ``C:\SciSoft\Python27``
is the directory where you installed EPD, edit
``C:\SciSoft\Python27\Scripts\ipython.bat``, there should be a line saying::
set path="C:\SciSoft\Python27";%path%
Remove the quotes around ``Python27``, leading to::
set path=C:\SciSoft\Python27;%path%
Then, it should work in all new terminals.
pip is not included in EPD, but you can simply install it with::
easy_install pip
Alternative: Canopy
+++++++++++++++++++
Canopy is another software that installs all Theano dependencies.
If you are affiliated with a university (as student or employee), you
can download the installation for free.
- Install Canopy x64, and update it to the latest version (`Help /
Software updates...`), as older Canopy versions have trouble installing
`pip`.
- Then install `pip` from Canopy Package Manager.
- In the Windows Prompt, type `pip install theano`.
- In Canopy Package Manager, search and install packages "mingw 4.5.2" and "libpython 1.2"
- (Needed only for Theano 0.6rc3 or earlier)
The "libpython 1.2" package installs files `libpython27.a` and `libmsvcr90.a` to
`C:\\Users\\<USER>\\AppData\\Local\\Enthought\\Canopy\\User\\libs`. Copy the two files to
`C:\\Users\\<USER>\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\libs`.
- (Needed only for Theano 0.6rc3 or earlier) Set the Theano flags
``blas.ldflags=-LC:\Users\<USER>\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\Scripts -lmk2_core -lmk2_intel_thread -lmk2_rt``.
Alternative: AnacondaCE
+++++++++++++++++++++++
ContinuumIO_ is providing a free Python distribution for Windows (32-bit
and 64-bit), including all dependencies of Theano. If you are not
eligible for a download of EPD or Canopy (via a commercial, or free academic
licence), this is the easiest way to install
Theano's dependencies. Simply download and execute the installer from
`AnacondaCE download page <http://continuum.io/anacondace.html>`__,
then download and execute the :ref:`windows_anaconda`.
.. _ContinuumIO: http://continuum.io
Alternative: Python(x,y)
++++++++++++++++++++++++
If you do not have a commercial licence of EPD, and are not eligible to a free
academic licence, and neither
Python nor MinGW is installed on your computer, you can install most
dependencies of Theano with `Python(x,y) <http://www.pythonxy.com>`__.
It is a single installation
file that contains additional packages like NumPy, SciPy, IPython, Matplotlib,
MinGW, Nose, etc.
Note however that there is no 64 bit version currently available.
You can keep the default install options, except that the installation
directory should not contain any blank space (in particular, do not install it
into ``C:\Program Files``).
Alternative: manual installation
++++++++++++++++++++++++++++++++
The following instructions provide steps for manual installation of all Theano
dependencies.
Note that it should be
possible to run Theano with `Cygwin <http://www.cygwin.com/>`__ instead of
MinGW, but this has not been tested yet.
- For 32 bit MinGW: from `the MinGW files <http://sourceforge.net/projects/mingw/files/>`__,
download the latest version of the ``Automated MinGW Installer``
(``mingw-get-inst``) and install it (you should install all optional components,
except the Objective C and Ada compilers which are not needed).
- For 64 bit MinGW (**note that manual installation for 64 bit is experimental**):
download the latest version of MinGW-w64 from the project's
`releases page <http://sourceforge.net/projects/mingw-w64/files/>`__, and extract
it for instance to ``C:\mingw64``. Also download MSYS from
`this page <http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/>`__
(although it is a 32-bit version of MSYS, this does not matter since it is only
a convenience tool). Extract MSYS into the same folder, so that, for instance, you
end up with ``C:\mingw64\msys``. Run ``C:\mingw64\msys\msys.bat`` and in the MSYS
shell, type
.. code-block:: bash
sh /postinstall/pi.sh
and answer the few questions so that MSYS is properly linked to your MinGW install.
- It is recommended to set your MSYS home to be the same as your Windows home
directory. This will avoid inconsistent behavior between running Theano
in a Windows command prompt vs. a MSYS shell. One way to do this without
setting a global Windows ``HOME`` environment variable (which may affect
other programs) is to edit your ``msys.bat`` file (found e.g. under
``C:\MinGW\msys\1.0`` or ``C:\mingw64\msys``) and add the following line at
the beginning (note that you may need to use e.g. Wordpad to edit this file,
since Notepad gets confused by Unix-style line breaks):
.. code-block:: bash
set HOME=%USERPROFILE%
- If you do not have them already, install the latest versions of
`Python 2.x <http://www.python.org/download/windows>`__ and
corresponding `NumPy <http://sourceforge.net/projects/numpy/files/>`__
then `SciPy <http://sourceforge.net/projects/scipy/files/>`__
packages (simply use the executable installers).
Note that there are currently no official 64 bit releases of NumPy and
SciPy, but you can find unofficial builds
`here <http://www.lfd.uci.edu/~gohlke/pythonlibs/>`__.
- Ensure that the Python installation directory and its ``Scripts``
sub-directory are in your system path. This may be done by
modifying the global ``PATH`` Windows environment variables, or by creating
a ``.profile`` file in your MinGW home, containing a line like
``export PATH=$PATH:/c/Python27:/c/Python27/Scripts`` (note that the latter
will work only when you run Theano from an MSYS shell).
- If you are installing the 64 bit version, you will need the following hack
to be able to compile Theano files with GCC (skip this step if you are using
the 32 bit version). In a temporary work directory, copy ``python27.dll``
(found in ``C:\\Windows\\System32``) as well as
`python27.def <http://wiki.cython.org/InstallingOnWindows?action=AttachFile&do=get&target=python27.def>`__.
Edit ``python27.def`` and replace ``Py_InitModule4`` with ``Py_InitModule4_64``.
Then open an MSYS shell, go to this temporary directory, and run:
.. code-block:: bash
dlltool --dllname python27.dll --def python27.def --output-lib libpython27.a
Finally, copy the libpython27.a file that was generated into your
``C:\\Python27\\libs`` folder.
- In order to run Theano's test-suite, you will need `nose
<http://somethingaboutorange.com/mrl/projects/nose>`__.
After unpacking its source code (you may use `7-zip
<http://www.7-zip.org/>`__), you can build and install it from within
its code directory by running the following command (either from a Windows
command prompt or an MSYS shell):
.. code-block:: bash
python setup.py install
Configuring the Environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~
At this point, you should have installed all Theano dependencies.
By default neither Python, GCC, nor Visual Studio was added to the
PATH. Save the following shell script as ``c:\scisoft\env.bat`` to
configure the system path:
.. code-block:: cmd
REM configuration of paths
set VSFORPYTHON="C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0"
set SCISOFT=%~dp0
REM add tdm gcc stuff
set PATH=%SCISOFT%\TDM-GCC-64\bin;%SCISOFT%\TDM-GCC-64\x86_64-w64-mingw32\bin;%PATH%
REM add winpython stuff
CALL %SCISOFT%\WinPython-64bit-2.7.6.4\scripts\env.bat
REM configure path for msvc compilers
REM for a 32 bit installation change this line to
REM CALL %VSFORPYTHON%\vcvarsall.bat
CALL %VSFORPYTHON%\vcvarsall.bat amd64
REM return a shell
cmd.exe /k
The script assumes that you installed WinPython distribution, update the winpython line otherwise.
For a 32 bit installation please change the indicated line to load
32-bit Microsoft Compilers.
You can access the Python shell by double-clicking on
``c:\scisoft\env.bat``. Please do so, and verify that the following
programs are found:
1. where gcc
2. where gendef
3. where cl
4. where nvcc
Finally we need to create a link library for GCC. Open up the Python
shell and ``cd`` to ``c:\SciSoft``. Then execute:
.. code-block:: cmd
gendef WinPython-64bit-2.7.6.4\python-2.7.6.amd64\python27.dll
dlltool --dllname python27.dll --def python27.def --output-lib WinPython-64bit-2.7.6.4\python-2.7.6.amd64\libs\libpython27.a
Installing Theano
~~~~~~~~~~~~~~~~~
Once the dependencies are installed, you can download and install
Theano. We have found that in the long run, the Git install is the
most useful, because you can update it with a single ``git pull``
command. Therefore we recommend it. However, a manual install without
Git is also possible.
Git Install
###########
Theano is hosted on GitHub, you need Git to download it. For Windows,
download and install the `MSYSGIT <http://msysgit.github.io/>`_ build.
Open up the `Git Shell` in the directory in which you want to install
Theano. For the bleeding-edge version execute
.. code-block:: bash
git clone https://github.com/Theano/Theano.git
For the latest stable release 0.6 (as of Oct 2014) run instead:
.. code-block:: bash
git clone https://github.com/Theano/Theano.git --branch rel-0.6
Either way, a folder `Theano` will be created with the library
downloaded to it.
Manual Installation
###################
To get the latest bleeding edge version got to `Theano on GitHub
<https://github.com/Theano/Theano>`_ and download the `latest zip
<https://github.com/Theano/Theano/archive/master.zip>`_. Then unzip it
somewhere.
Alternatively, you can check the latest release release 0.6 (as of Oct
2014) by going to
https://github.com/Theano/Theano/releases/tag/rel-0.6 and
downloading the `zip
<https://github.com/Theano/Theano/archive/rel-0.6.zip>`_.
Configuring Theano
##################
Once you have installed Theano, open the Python Shell
(e.g. ``c:\scisoft\env.bat`` if you follow the installation directories
from this tutorial) and ``cd`` to it. Then run::
python setup.py develop
this step will add the Theano directory to you ``PYTHON_PATH``
environment variable.
At this stage you can check whether Theano works and is able to
compile C code for CPU execution.
Create a test file containing:
.. code-block:: python
import numpy as np
import time
import theano
A = np.random.rand(1000,10000).astype(theano.config.floatX)
B = np.random.rand(10000,1000).astype(theano.config.floatX)
np_start = time.time()
AB = A.dot(B)
np_end = time.time()
X,Y = theano.tensor.matrices('XY')
mf = theano.function([X,Y],X.dot(Y))
t_start = time.time()
tAB = mf(A,B)
t_end = time.time()
print "NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" %(
np_end-np_start, t_end-t_start)
print "Result difference: %f" % (np.abs(AB-tAB).max(), )
Then run it. It should execute without problems and the Theano function
should run at a speed similar to the regular NumPy
multiplication. (Both Numpy and Theano should call the same BLAS
routine for matrix multiplication)
Configure Theano for GPU use
############################
Theano can be configured with a ``.theanorc`` text file (or
``.theanorc.txt``, whichever is easier for you to create under
Windows). It should be placed in the directory pointed to by the
``%USERPROFILE%`` variable. Please note, that WinPython changes it to
``WinPythonDir\settings`` (so in our system this corresponds to
``c:\scisoft\WinPython-64bit-2.7.6.4\settings``.
To use the GPU please write the following configuration file:
.. code-block:: cfg
[global]
device = gpu
floatX = float32
[nvcc]
flags = --use-local-env --cl-version=2008
Rerun the simple test file and verify that it runs. Depending on you
GPU, the theano function should run on the GPU much faster than the
CPU matrix multiplication performed by NumPy.
You can also find additional test code and useful GPU tips on the
:ref:`using_gpu` page.
Running Theano's test-suite
###########################
Currently, due to memory fragmentation issue in Windows, the
test-suite breaks at some point when using ``theano-nose``, with many error
messages looking
like: ``DLL load failed: Not enough storage is available to process this
command``. As a workaround, you can instead run:
.. code-block:: bash
theano-nose --batch
This will run tests in batches of 100, which should avoid memory errors.
Note that this script calls ``nosetests``, which may require being run from
within an MSYS shell if you installed Nose manually as described above.
.. note::
In Theano versions <= 0.5, ``theano-nose`` was not included. If you
are working with such a version, you can call this command instead:
.. code-block:: bash
python theano/tests/run_tests_in_batch.py
Compiling a faster BLAS
~~~~~~~~~~~~~~~~~~~~~~~
If you installed Python through WinPython or EPD, Theano will automatically
link with the MKL library, so you should not need to compile your own BLAS.
.. note::
The instructions below have not been tested in a Windows 64 bit environment.
If you want a faster and/or multi-threaded BLAS library, you can
compile OpenBLAS (ATLAS may work too, but was not tested, and is
usually reported to be slower and more difficult to compile -- especially
on Windows).
OpenBLAS can be downloaded as a zip file from
`its website <http://xianyi.github.io/OpenBLAS/>`__
(we tested v0.2.6).
To compile it, you will also need MSYS and wget (installation steps are
described below).
If you already have a full install of MinGW, you should
have MSYS included in it, and thus should be able to start a MinGW shell.
If that is the case, you can skip the following MSYS installation steps.
Note that these steps were written for Python(x,y), but should also work
for other bundle Python distributions like EPD (changing paths accordingly,
for instance in EPD 7.3.2 the MinGW folder is
``EPD7.3.2\EGG-INFO\mingw\usr\i686-w64-mingw32``).
To install MSYS on top of the MinGW installation included within Python(x,y),
do as follows:
- Download the `mingw-get command-line installer binary
<http://sourceforge.net/projects/mingw/files/Installer/mingw-get/>`__.
- Unpack its content into your ``pythonxy\mingw`` directory.
- In a prompt (``cmd``), install MSYS with
.. code-block:: bash
mingw-get install msys-base
If ``mingw-get`` cannot be found automatically, just navigate first into the
folder were it was extracted (it is found in the ``bin`` subfolder).
- Edit ``pythonxy\mingw\msys\1.0\msys.bat`` (e.g. in Wordpad) and add as first
line ``set HOME=%USERPROFILE%``. Then create an easily accessible shortcut
(e.g. on your desktop) to this file, run it and within the MSYS
console, run the MSYS post-install script:
.. code-block:: bash
/postinstall/pi.sh
It will ask for your MinGW installation directory (e.g.
``c:/pythonxy/mingw``; note the forward slashes).
Once you have a working MinGW/MSYS shell environment, you can go on as
follows:
a) Install ``wget`` by running the setup program you can download on the
`wget website <http://gnuwin32.sourceforge.net/packages/wget.htm>`__.
Note that this setup does not add ``wget`` into the system PATH, so you
will need to modify the ``PATH`` environment variable accordingly (either in
Windows or in a ``.profile`` startup file in your MinGW home). Once this is done,
type ``wget --version`` in a MinGW shell to verify that it is running
properly. Note also that if you are behind a proxy, you should set up your
``HTTP_PROXY`` environment variable, or use a custom ``wgetrc`` config file
for wget to be able to download files.
b) Unzip OpenBLAS and, in a MinGW shell, go into the corresponding directory.
c) Compile OpenBLAS with:
.. code-block:: bash
quickbuild.win32 1>log.txt 2>err.txt
(use ``quickbuild.win64`` for 64-bit Windows).
Compilation can take a while, so now is a good time to take a break.
When it is done, you should have ``libopenblas.dll`` in your OpenBLAS
folder. If that is not the case, check the ``err.txt`` log for build errors.
d) Make sure that ``libopenblas.dll`` is in a folder that is in your ``PATH``.
e) Modify your .theanorc (or .theanorc.txt) with
``ldflags = -LX:\\YYY\\ZZZ -lopenblas`` where ``X:\\YYY\\ZZZ`` is the path
to the folder containing ``libopenblas.dll``.
This setting can also be changed in Python for testing purpose (in which
case it will remain only for the duration of your Python session):
.. code-block:: python
theano.config.blas.ldflags = "-LX:\\YYY\\YYY -lopenblas"
f) To test the BLAS performance, you can run the script
``theano/misc/check_blas.py``.
Note that you may control the number of threads used by OpenBLAS with
the ``OPENBLAS_NUM_THREADS`` environment variable (default behavior is to use
all available cores).
Here are some performance results on an Intel Core2 Duo 1.86 GHz,
compared to using NumPy's BLAS or the un-optimized standard BLAS
(compiled manually from its source code).
Note that we report here results for GotoBLAS2 which is the ancestor of
OpenBLAS (this benchmark still needs to be updated with OpenBLAS results):
* GotoBLAS2 (2 threads): 16s
* NumPy (1 thread): 48s
* Standard BLAS (un-optimized, 1 thread): 166s
Conclusions:
* The unoptimized standard BLAS is very slow and should not be used.
* The Windows binaries of NumPy were compiled with ATLAS and are surprisingly fast.
* GotoBLAS2 is even faster, in particular if you can use multiple cores.
.. note::
If you get a ``DLL load failed`` error message, it typically means that
a required DLL was not found in the PATH. If it happens only when you are
using OpenBLAS, it means it is either ``libopenblas.dll`` itself or one of its
dependencies. In the case where it is a dependency, you can use the
`Dependency Walker <http://www.dependencywalker.com/>`__ utility to figure out
which one.
.. _gpu_windows:
theano/sandbox/cuda/nvcc_compiler.py
浏览文件 @
7dc5cf52
...
@@ -295,6 +295,7 @@ class NVCC_compiler(object):
...
@@ -295,6 +295,7 @@ class NVCC_compiler(object):
'-fmad'
,
'-ftz'
,
'-maxrregcount'
,
'-fmad'
,
'-ftz'
,
'-maxrregcount'
,
'-prec-div'
,
'-prec-sqrt'
,
'-use_fast_math'
,
'-prec-div'
,
'-prec-sqrt'
,
'-use_fast_math'
,
'--use-local-env'
,
'--cl-version='
]:
'--use-local-env'
,
'--cl-version='
]:
if
pa
.
startswith
(
pattern
):
if
pa
.
startswith
(
pattern
):
preargs1
.
append
(
pa
)
preargs1
.
append
(
pa
)
preargs2
=
[
pa
for
pa
in
preargs
preargs2
=
[
pa
for
pa
in
preargs
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论