提交 ef3f524a authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merge pull request #550 from lamblin/win64_install

Installation instructions, and test fixes, for windows
...@@ -7,6 +7,7 @@ Documentation ...@@ -7,6 +7,7 @@ Documentation
This explains how to make a Theano Op from a Python function. This explains how to make a Theano Op from a Python function.
http://deeplearning.net/software/theano/tutorial/extending_theano.html http://deeplearning.net/software/theano/tutorial/extending_theano.html
(Frédéric B.) (Frédéric B.)
* New installation instructions for Windows using EPD (Pascal L.)
Interface changes Interface changes
* In 0.5, we removed the deprecated sharedvar.value property. * In 0.5, we removed the deprecated sharedvar.value property.
...@@ -46,6 +47,8 @@ Sparse Sandbox Additions (not reviewed/documented/tested, but used by some peopl ...@@ -46,6 +47,8 @@ Sparse Sandbox Additions (not reviewed/documented/tested, but used by some peopl
Internal changes Internal changes
* Define new exceptions MissingInputError and UnusedInputError, and use them * Define new exceptions MissingInputError and UnusedInputError, and use them
in theano.function, instead of TypeError and ValueError. (Pascal L.) in theano.function, instead of TypeError and ValueError. (Pascal L.)
* Better handling of bitwidth and max values of integers and pointers
across platforms (Pascal L.)
Crash Fix Crash Fix
* Do not try to use the BLAS library when blas.ldflags is manually set to an * Do not try to use the BLAS library when blas.ldflags is manually set to an
...@@ -62,6 +65,8 @@ Crash Fix ...@@ -62,6 +65,8 @@ Crash Fix
(Frederic B., reported by Sander Dieleman) (Frederic B., reported by Sander Dieleman)
* GpuSoftmaxWithBias with shape (0, N) with N > 1. * GpuSoftmaxWithBias with shape (0, N) with N > 1.
(Frédéric B., reported by Razvan P.) (Frédéric B., reported by Razvan P.)
* Fix crash under 64-bit Windows, when taking subtensors of the form a[n:]
(Pascal L., reported by Simon McGregor)
============= =============
Release Notes Release Notes
......
...@@ -289,6 +289,7 @@ node representing the application of Op ``mul`` to inputs ``x`` and ...@@ -289,6 +289,7 @@ node representing the application of Op ``mul`` to inputs ``x`` and
``y``, giving a Variable instance of type ``double`` as the output. ``y``, giving a Variable instance of type ``double`` as the output.
.. note:: .. note::
Theano relies on the fact that if you call the ``make_node`` method Theano relies on the fact that if you call the ``make_node`` method
of Apply's first argument on the inputs passed as the Apply's of Apply's first argument on the inputs passed as the Apply's
second argument, the call will not fail and the returned Apply second argument, the call will not fail and the returned Apply
...@@ -315,6 +316,7 @@ contain a single storage cell for the multiplication's variable. ...@@ -315,6 +316,7 @@ contain a single storage cell for the multiplication's variable.
Here, ``z`` is a list of one element. By default, ``z == [None]``. Here, ``z`` is a list of one element. By default, ``z == [None]``.
.. note:: .. note::
It is possible that ``z`` does not contain ``None``. If it contains It is possible that ``z`` does not contain ``None``. If it contains
anything else, Theano guarantees that whatever it contains is what anything else, Theano guarantees that whatever it contains is what
``perform`` put there the last time it was called with this ``perform`` put there the last time it was called with this
...@@ -324,6 +326,7 @@ Here, ``z`` is a list of one element. By default, ``z == [None]``. ...@@ -324,6 +326,7 @@ Here, ``z`` is a list of one element. By default, ``z == [None]``.
:ref:`op` documentation. :ref:`op` documentation.
.. warning:: .. warning::
We gave ``z`` the Theano type ``double`` in ``make_node``, which means We gave ``z`` the Theano type ``double`` in ``make_node``, which means
that a Python ``float`` must be put there. You should not put, say, an that a Python ``float`` must be put there. You should not put, say, an
``int`` in ``z[0]`` because Theano assumes Ops handle typing properly. ``int`` in ``z[0]`` because Theano assumes Ops handle typing properly.
......
...@@ -232,6 +232,7 @@ arithmetics that your Ops implement. Theano might provide facilities ...@@ -232,6 +232,7 @@ arithmetics that your Ops implement. Theano might provide facilities
for this somewhere in the future. for this somewhere in the future.
.. note:: .. note::
:class:`Env` is a Theano structure intended for the optimization :class:`Env` is a Theano structure intended for the optimization
phase. It is used internally by function and Module and is rarely phase. It is used internally by function and Module and is rarely
exposed to the end user. You can use it to test out optimizations, exposed to the end user. You can use it to test out optimizations,
......
...@@ -98,6 +98,7 @@ case if ``borrow`` was True, the thunk would be allowed to reuse (or ...@@ -98,6 +98,7 @@ case if ``borrow`` was True, the thunk would be allowed to reuse (or
"recycle") the storage). "recycle") the storage).
.. note:: .. note::
Compiled libraries are stored within a specific compilation directory, Compiled libraries are stored within a specific compilation directory,
which by default is set to ``$HOME/.theano/compiledir_xxx``, where which by default is set to ``$HOME/.theano/compiledir_xxx``, where
``xxx`` identifies the platform (under Windows the default location ``xxx`` identifies the platform (under Windows the default location
......
...@@ -600,7 +600,51 @@ Windows ...@@ -600,7 +600,51 @@ Windows
Installing Dependencies Installing Dependencies
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
If neither Python nor MinGW is installed on your computer, the easiest way to 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) <epd>`_.
If you are affiliated to 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
.. _epd: http://enthought.com/products/epd.php
.. _Graphviz: http://www.graphviz.org/Download_windows.php
Alternative: Python(x,y)
########################
If you are not eligible to a free download of EPD, and
neither Python nor MinGW is installed on your computer, the easiest way to
install most dependencies is to install install most dependencies is to install
`Python(x,y) <http://www.pythonxy.com>`__. `Python(x,y) <http://www.pythonxy.com>`__.
It is a single installation It is a single installation
...@@ -664,20 +708,28 @@ components as in Python(x,y) that are required by Theano, follow these steps: ...@@ -664,20 +708,28 @@ components as in Python(x,y) that are required by Theano, follow these steps:
At this point, whether you installed Python(x,y) or individual components, you At this point, whether you installed Python(x,y) or individual components, you
should have MinGW, Python, Numpy, Scipy and Nose installed. should have MinGW, Python, Numpy, Scipy and Nose installed.
In order to download Theano you will also need 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).
Installing Theano Installing Theano
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
It should be possible to install Theano with ``pip`` as described in It is possible to install Theano with ``pip`` as described in
:ref:`linux_basic`, but this has not been tested yet under Windows. We describe :ref:`linux_basic`. However, if you want to get the latest development version,
or edit the code, you should follow the instructions below.
Bleeding-edge installation
##########################
We describe
here instructions to use the latest code repository version (bleeding-edge). here instructions to use the latest code repository version (bleeding-edge).
Command lines listed below are assumed to be run in a Windows prompt 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 (click ``Start`` and type the ``cmd`` command), and may need to be adapted if
used within a MinGW Shell (not available if you only installed Python(x,y)). used within a MinGW Shell (not available if you only installed Python(x,y)).
You will need 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).
- Navigate into the directory you want Theano to be installed in, and download - Navigate into the directory you want Theano to be installed in, and download
it with it with
...@@ -695,6 +747,13 @@ used within a MinGW Shell (not available if you only installed Python(x,y)). ...@@ -695,6 +747,13 @@ used within a MinGW Shell (not available if you only installed Python(x,y)).
C:\Users\login>echo %PYTHONPATH% C:\Users\login>echo %PYTHONPATH%
C:\Users\login\Theano C:\Users\login\Theano
Configure Theano
################
If you installed Python through EPD, 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 - 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 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 are into when you start a new command prompt with ``cmd``), containing the
...@@ -762,6 +821,9 @@ the Visual Studio editor. ...@@ -762,6 +821,9 @@ the Visual Studio editor.
Compiling a faster BLAS 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:: .. note::
GotoBLAS is no longer maintained and has been released under the BSD GotoBLAS is no longer maintained and has been released under the BSD
......
...@@ -57,8 +57,9 @@ import getopt ...@@ -57,8 +57,9 @@ import getopt
from collections import defaultdict from collections import defaultdict
if __name__ == '__main__': if __name__ == '__main__':
# Equivalent of sys.path[0]/../..
throot = "/".join(sys.path[0].split("/")[:-2]) throot = os.path.abspath(
os.path.join(sys.path[0], os.pardir, os.pardir))
options = defaultdict(bool) options = defaultdict(bool)
options.update(dict([x, y or True] for x, y in options.update(dict([x, y or True] for x, y in
...@@ -91,7 +92,7 @@ if __name__ == '__main__': ...@@ -91,7 +92,7 @@ if __name__ == '__main__':
# Make sure the appropriate 'theano' directory is in the PYTHONPATH # Make sure the appropriate 'theano' directory is in the PYTHONPATH
pythonpath = os.environ.get('PYTHONPATH', '') pythonpath = os.environ.get('PYTHONPATH', '')
pythonpath = throot + ':' + pythonpath pythonpath = os.pathsep.join([throot, pythonpath])
os.environ['PYTHONPATH'] = pythonpath os.environ['PYTHONPATH'] = pythonpath
if options['--all'] or options['--epydoc']: if options['--all'] or options['--epydoc']:
......
...@@ -250,7 +250,7 @@ class Test_SharedVariable(unittest.TestCase): ...@@ -250,7 +250,7 @@ class Test_SharedVariable(unittest.TestCase):
f(b, 8) f(b, 8)
assert b.get_value() == 8 assert b.get_value() == 8
b = shared(numpy.zeros((5, 5), dtype='float32'), allow_downcast=True) b = shared(numpy.zeros((5, 5), dtype='float32'))
self.assertRaises(TypeError, f, b, numpy.random.rand(5, 5)) self.assertRaises(TypeError, f, b, numpy.random.rand(5, 5))
def test_tensor_floatX(self): def test_tensor_floatX(self):
...@@ -303,6 +303,5 @@ class Test_SharedVariable(unittest.TestCase): ...@@ -303,6 +303,5 @@ class Test_SharedVariable(unittest.TestCase):
f(b, [8]) f(b, [8])
assert b.get_value() == 8 assert b.get_value() == 8
b = shared(numpy.zeros((5, 5), dtype='float32'), b = shared(numpy.zeros((5, 5), dtype='float32'))
allow_downcast=True)
self.assertRaises(TypeError, f, b, numpy.random.rand(5, 5)) self.assertRaises(TypeError, f, b, numpy.random.rand(5, 5))
...@@ -1429,6 +1429,13 @@ class GCC_compiler(object): ...@@ -1429,6 +1429,13 @@ class GCC_compiler(object):
# Under Windows it looks like fPIC is useless. Compiler warning: # Under Windows it looks like fPIC is useless. Compiler warning:
# '-fPIC ignored for target (all code is position independent)' # '-fPIC ignored for target (all code is position independent)'
preargs.append('-fPIC') preargs.append('-fPIC')
if sys.platform == 'win32' and local_bitwidth() == 64:
# Under 64-bits windows installation, sys.platform is 'win32'.
# We need to define MS_WIN64 for the preprocessor to be able to
# link with libpython.
preargs.append('-DMS_WIN64')
no_opt = False no_opt = False
include_dirs = include_dirs + std_include_dirs() include_dirs = include_dirs + std_include_dirs()
......
...@@ -341,10 +341,13 @@ def constant_or_value(x, rtype, name=None, ndim=None, dtype=None): ...@@ -341,10 +341,13 @@ def constant_or_value(x, rtype, name=None, ndim=None, dtype=None):
elif rtype is TensorConstant and isinstance(x, float): elif rtype is TensorConstant and isinstance(x, float):
x_ = autocast_float(x) x_ = autocast_float(x)
elif rtype is TensorConstant and isinstance(x, long): elif rtype is TensorConstant and isinstance(x, long):
# It is not clear what would happen if one was to use a `long` # We need to address the case where a long number is used in a
# number as a constant in a Theano graph. As a result, we throw # Theano graph, because on Windows 64, all shapes are expressed
# an exception in this situation. # with longs.
raise NotImplementedError('Constants of type `long` not supported') # If a long fits in int64, we convert it into an int64, like
# numpy.asarray() does.
# If x is too big, an OverflowError will be raised by numpy.
x_ = theano._asarray(x, dtype='int64')
elif isinstance(x, numpy.ndarray): elif isinstance(x, numpy.ndarray):
x_ = x x_ = x
# Currently we do not have a bool dtype in Theano. # Currently we do not have a bool dtype in Theano.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论