提交 c5d3942b authored 作者: Francesco's avatar Francesco 提交者: GitHub

[WIP] Documentation Refactor 2 (#4775)

* Installation documentation refactor * Remove the extra install links from the homepage * Restore pics * Rename css extension to suppress warning * Fix install is not a toctree so is not indexed * Fix multiple labels with same name * Fix stdint.h link * Remove reference to old GCC download instructions * Fix colors * Fix installation instructions * Fix troubleshooting * Fix broken link in dev_start_guide * Prevent doc generation script from using GPUs * Add numpy and scipy max version * Remove Canopy references * Fix script fails if THEANO_FLAGS is not set * Add warning for deprecation of the old backend + minor changes * Default env_th_flags should be an empty string * Remove PYTHONPATH reference from doc, add libgpuarray options first * Add static link to the dev installation instructions * Fix syntax of link
上级 f5207388
.. _css:
.. raw:: html
<style> .black {color:black} </style>
<style> .blue {color:blue} </style>
<style> .red {color:red} </style>
<style> .green {color:green} </style>
<style> .pink {color:pink} </style>
.. role:: blue
.. role:: red
.. role:: green
.. role:: pink
.. role:: black
......@@ -10,7 +10,7 @@ Contributing
You want to contribute to Theano? That is great! This page explain our
workflow and some resource for doing so.
Looking for an idea for a first contribution? Check `github issue
Looking for an idea for a first contribution? Check the `github issues
<https://github.com/Theano/Theano/issues?q=is%3Aopen+is%3Aissue+label%3A%22Easy+fix%22>`_
with a label ``easy fix``. They are good starter. It is recommanded
that you write on the issue you want to work on it. This help make
......@@ -85,8 +85,8 @@ make sure there are no global impacts.
Also, if you are changing GPU code, travis doesn't test that, because
there are no GPUs on the test nodes.
To run the test suite with the default options, you can follow the
instructions of :ref:`testing_installation`.
To run the test suite with the default options, see
:ref:`test_theano`.
Each night we execute all the unit tests automatically, with several
sets of options. The result is sent by email to the `theano-buildbot`_
......@@ -364,7 +364,7 @@ You can choose another name than "central" to reference Theano/Theano
to "central."
You can then test your installation of Theano by following the steps of
:ref:`testing_installation`.
:ref:`test_theano`.
Using your local copy
......
......@@ -10,21 +10,6 @@ Does Theano support Python 3?
------------------------------
We support both Python 2 >= 2.6 and Python 3 >= 3.3.
TypeError: object of type 'TensorVariable' has no len()
-------------------------------------------------------
If you receive the following error, it is because the Python function *__len__* cannot
be implemented on Theano variables:
.. code-block:: python
TypeError: object of type 'TensorVariable' has no len()
Python requires that *__len__* returns an integer, yet it cannot be done as Theano's variables are symbolic. However, `var.shape[0]` can be used as a workaround.
This error message cannot be made more explicit because the relevant aspects of Python's
internals cannot be modified.
Output slight numerical difference
----------------------------------
......@@ -39,7 +24,6 @@ Every Computer Scientist Should Know About Floating-Point Arithmetic
<https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html>`_.
Faster gcc optimization
-----------------------
......@@ -179,33 +163,6 @@ but requires that all nodes in the graph have a C implementation:
f(10.)
Out of memory... but not really
-------------------------------
Occasionally Theano may fail to allocate memory when there appears to be more
than enough reporting:
Error allocating X bytes of device memory (out of memory). Driver report Y
bytes free and Z total.
where X is far less than Y and Z (i.e. X << Y < Z).
This scenario arises when an operation requires allocation of a large contiguous
block of memory but no blocks of sufficient size are available.
GPUs do not have virtual memory and as such all allocations must be assigned to
a continuous memory region. CPUs do not have this limitation because or their
support for virtual memory. Multiple allocations on a GPU can result in memory
fragmentation which can makes it more difficult to find contiguous regions
of memory of sufficient size during subsequent memory allocations.
A known example is related to writing data to shared variables. When updating a
shared variable Theano will allocate new space if the size of the data does not
match the size of the space already assigned to the variable. This can lead to
memory fragmentation which means that a continugous block of memory of
sufficient capacity may not be available even if the free memory overall is
large enough.
Related Projects
----------------
......@@ -226,55 +183,3 @@ Here is a list of some of the known limitations:
interact with the rest of the graph).
- Neither *goto* nor *recursion* is supported or planned within expression graphs.
"float32 / int{32, 64} gives float64"
-------------------------------------
It should be noted that using float32 and int{32, 64} together
inside a function would provide float64 as output.
Since the GPU can't compute this kind of output, it would be
preferable not to use those dtypes together.
To help you find where float64 are created, see the
:attr:`warn_float64` Theano flag.
Theano memory/speed trade-off
-----------------------------
There is a few things you can easily do to change the trade-off
between speed and memory usage. It nothing is said, this affect the
CPU and GPU memory usage.
Could speed up and lower memory usage:
- :ref:`cuDNN <libdoc_cuda_dnn>` default cuDNN convolution use less
memory then Theano version. But some flags allow it to use more
memory. GPU only.
- Shortly avail, multi-GPU.
Could raise memory usage but speed up computation:
- :attr:`config.lib.cnmem` =1 # Do not raise much memory usage, but if you are at the limit of GPU memory available. GPU only.
- :attr:`config.allow_gc` =False
- :attr:`config.optimizer_excluding` =low_memory , GPU only for now.
Could lower the memory usage, but raise computation time:
- :attr:`config.scan.allow_gc` =True # Probably not significant slowdown if config.lib.cnmem is used.
- :attr:`config.scan.allow_output_prealloc` =False
- Use :func:`batch_normalization()
<theano.tensor.nnet.bn.batch_normalization>`. It use less memory
then building a corresponding Theano graph.
- Disable one or scan more optimizations:
- ``optimizer_excluding=scanOp_pushout_seqs_ops``
- ``optimizer_excluding=scan_pushout_dot1``
- ``optimizer_excluding=scanOp_pushout_output``
- Disable all optimization tagged as raising memory usage:
``optimizer_excluding=more_mem`` (currently only the 3 scan optimizations above)
- `float16 <https://github.com/Theano/Theano/issues/2908>`_.
If you want to analyze the memory usage during computation, the
simplest is to let the memory error happen during Theano execution and
use the Theano flags :attr:`exception_verbosity=high`.
......@@ -125,6 +125,7 @@ Roughly in order of what you'll want to check out:
* :ref:`install` -- How to install Theano.
* :ref:`introduction` -- What is Theano?
* :ref:`tutorial` -- Learn the basics.
* :ref:`troubleshooting` -- Tips and tricks for common debugging.
* :ref:`libdoc` -- Theano's functionality, module by module.
* :ref:`faq` -- A set of commonly asked questions.
* :ref:`optimizations` -- Guide to Theano's graph optimizations.
......@@ -237,12 +238,15 @@ StackOverflow, follow their guidance for `answering questions <http://stackoverf
NEWS
introduction
requirements
install
updating
tutorial/index
extending/index
dev_start_guide
optimizations
library/index
troubleshooting
glossary
links
internal/index
......
差异被折叠。
:orphan:
.. include:: css.inc
.. _install_centos6:
CentOS 6 Installation Instructions
##################################
Easy Installation of an optimized Theano on CentOS 6
====================================================
.. 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_centos6.html>`_.
.. note::
.. include:: requirements.txt
It is possible to have a faster installation of Theano than the one these
instructions will provide, but this will make the installation more
complicated and/or may require that you buy software. This is a simple set
of installation instructions that will leave you with a relatively
well-optimized version that uses only free software. With more work or by
investing money (i.e. buying a license to a proprietary BLAS
implementation), it is possible to gain further performance.
.. include:: install_generic.inc
:start-line: 5
.. note::
If you are behind a proxy, you must do some extra configuration steps
before starting the installation. You must set the environment
variable ``http_proxy`` to the proxy address. Using bash this is
accomplished with the command
``export http_proxy="http://user:pass@my.site:port/"``
You can also provide the ``--proxy=[user:pass@]url:port`` parameter
to pip. The ``[user:pass@]`` portion is optional.
.. note::
We use ``pip`` for 2 reasons. First, it allows "``import module;
module.test()``" to work correctly. Second, the installation of NumPy
1.6 or 1.6.1 with ``easy_install`` raises an ImportError at the end of
the installation. To my knowledge we can ignore this error, but
this is not completely safe. ``easy_install`` with NumPy 1.5.1 does not
raise this error.
Installation steps
~~~~~~~~~~~~~~~~~~
1) ``sudo yum install python-devel python-nose python-setuptools gcc
gcc-gfortran gcc-c++ blas-devel lapack-devel atlas-devel``
2) ``sudo easy_install pip``
3) ``sudo pip install numpy==1.6.1``
4) ``sudo pip install scipy==0.10.1``
5) ``sudo pip install Theano``
Test the newly installed packages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) NumPy (~30s): ``python -c "import numpy; numpy.test()"``
2) SciPy (~1m): ``python -c "import scipy; scipy.test()"``
3) Theano (~30m): ``python -c "import theano; theano.test()"``
Speed test Theano/BLAS
~~~~~~~~~~~~~~~~~~~~~~
It is recommended to test your Theano/BLAS integration. There are many versions
of BLAS that exist and there can be up to 10x speed difference between them.
Also, having Theano link directly against BLAS instead of using NumPy/SciPy as
an intermediate layer reduces the computational overhead. This is
important for BLAS calls to ``ger``, ``gemv`` and small ``gemm`` operations
(automatically called when needed when you use ``dot()``). To run the
Theano/BLAS speed test:
Requirements through System Packages (not recommended)
------------------------------------------------------
.. code-block:: bash
python /usr/lib/python2.*/site-packages/theano/misc/check_blas.py
This will print a table with different versions of BLAS/numbers of
threads on multiple CPUs and GPUs. It will also print some Theano/NumPy
configuration information. Then, it will print the running time of the same
benchmarks for your installation. Try to find a CPU similar to yours in
the table, and check that the single-threaded timings are roughly the same.
Updating Theano
~~~~~~~~~~~~~~~
If you followed these installation instructions, you can execute this command
to update only Theano:
.. code-block:: bash
sudo pip install --upgrade --no-deps theano
If you want to also update NumPy/SciPy, you can run this:
.. code-block:: bash
sudo pip install --upgrade theano
Bleeding edge
~~~~~~~~~~~~~
Do like in the section "Updating Theano", but use
``git+git://github.com/Theano/Theano.git`` instead of ``theano``.
sudo yum install python-devel python-nose python-setuptools gcc gcc-gfortran gcc-c++ blas-devel lapack-devel atlas-devel
sudo easy_install pip
.. include:: css.inc
.. _install_generic:
Installation
============
Stable Installation
-------------------
Install the latest stable version of Theano with:
.. raw:: html
<div class="highlight"><pre><span class="red">&lt;sudo&gt;</span> pip install <span class="blue">&lt;--user&gt;</span> Theano[test, doc]</pre></div>
- Any argument between <...> is optional.
- Use :red:`sudo` for a root installation.
- Use :blue:`user` for a user installation without admin rights. It will install Theano in your local site-packages.
- [test] will install the requirements for testing.
- [doc] will install the requirements in order to generate the documentation.
If you encountered any trouble, head to the :ref:`troubleshooting` page.
libgpuarray
^^^^^^^^^^^
For the stable version of Theano you need a specific version of libgpuarray,
that has been tagged ``v-9998``.
Download it with:
.. raw:: html
<div class='highlight'><pre>
git clone https://github.com/Theano/libgpuarray.git --tags
git checkout origin/v-9998
cd libgpuarray
</pre></div>
and then follow the `Step-by-step instructions <http://deeplearning.net/software/libgpuarray/installation.html#step-by-step-install>`__.
Bleeding-Edge Installation (recommended)
----------------------------------------
Install the latest, bleeding-edge, development version of Theano with:
.. raw:: html
<div class='highlight'><pre><span class="red">&lt;sudo&gt;</span> pip install <span class="blue">&lt;--user&gt;</span> <span class="pink">&lt;--no-deps&gt;</span> git+https://github.com/Theano/Theano.git#egg=Theano</pre></div>
- Any argument between <...> is optional.
- Use :red:`sudo` for a root installation.
- Use :blue:`user` for a user installation without admin rights. It will install Theano in your local site-packages.
- Use :pink:`no-deps` when you don't want the dependencies of Theano to be installed through pip. This is important when they have already been installed as system packages.
If you encountered any trouble, head to the :ref:`troubleshooting` page.
libgpuarray
^^^^^^^^^^^
Install the latest, development version of libgpuarray following the
`Step-by-step instructions <http://deeplearning.net/software/libgpuarray/installation.html#step-by-step-install>`__.
Developer Installation
----------------------
Install the developer version of Theano with:
.. raw:: html
<div class="highlight"><pre>git clone git://github.com/Theano/Theano.git
cd Theano
<span class="red">&lt;sudo&gt;</span> pip install <span class="blue">&lt;--user&gt;</span> <span class="pink">&lt;--no-deps&gt;</span> <span class="green">-e .</span></pre></div>
- Any argument between <...> is optional.
- Use :red:`sudo` for a root installation.
- Use :blue:`user` for a user installation without admin rights. It will install Theano in your local site-packages.
- Use :pink:`no-deps` when you don't want the dependencies of Theano to be installed through pip. This is important when they have already been installed as system packages.
- :green:`-e` makes your installation *editable*, i.e., it links it to your
source directory.
If you encountered any trouble, head to the :ref:`troubleshooting` page.
libgpuarray
^^^^^^^^^^^
Install the latest, development version of libgpuarray following the
`Step-by-step instructions <http://deeplearning.net/software/libgpuarray/installation.html#step-by-step-install>`__.
.. include:: css.inc
.. _install_macos:
Mac OS 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_macos.html>`_.
There are various ways to install Theano dependencies on a Mac. Here
we describe the process in detail with Anaconda, Homebrew or MacPorts
but if you did it differently and it worked, please let us know the
details on the `theano-users`_ mailing-list, so that we can add
alternative instructions here.
.. _theano-users: http://groups.google.com/group/theano-users?pli=1
.. include:: requirements.txt
.. _gpu_macos:
.. attention::
For MacOS you should be able to follow the above instructions to
setup CUDA, but be aware of the following caveats:
* If you want to compile the CUDA SDK code, you may need to temporarily
revert back to Apple's gcc (``sudo port select gcc``) as their Makefiles
are not compatible with MacPort's gcc.
* If CUDA seems unable to find a CUDA-capable GPU, you may need to manually
toggle your GPU on, which can be done with
`gfxCardStatus <http://codykrieger.com/gfxCardStatus>`__.
.. attention::
Theano officially supports only clang on OS X. This can be installed
by getting XCode from the App Store and running it once to install the
command-line tools.
.. include:: install_generic.inc
:start-line: 5
Requirements through Homebrew (not recommended)
-----------------------------------------------
Install python with homebrew:
.. code-block:: bash
$ brew install python # or python3 if you prefer
This will install pip. Then use pip to install numpy, scipy:
.. code-block:: bash
$ pip install numpy scipy
If you want to use openblas instead of Accelerate, you have to install
numpy and scipy with hombrew:
.. code-block:: bash
$ brew tap homebrew/python
$ brew install numpy --with-openblas
$ brew install scipy --with-openblas
Requirements through MacPorts (not recommended)
-----------------------------------------------
Using `MacPorts <http://www.macports.org/>`__ to install all required
Theano dependencies is easy, but be aware that it will take a long time
(a few hours) to build and install everything.
- MacPorts requires installing XCode first (which can be found in the
Mac App Store), if you do not have it already.
If you can't install it from the App Store, look in your MacOS X installation
DVD for an old version. Then update your Mac to update XCode.
- Download and install `MacPorts <http://www.macports.org/>`__, then
ensure its package list is up-to-date with ``sudo port selfupdate``.
- Then, in order to install one or more of the required libraries, use
``port install``, e.g. as follows:
.. code-block:: bash
$ sudo port install py27-numpy +atlas py27-scipy +atlas py27-pip
This will install all the required Theano dependencies. gcc will
be automatically installed (since it is a SciPy dependency), but be
aware that it takes a long time to compile (hours)!
Having NumPy and SciPy linked with ATLAS (an optimized BLAS
implementation) is not mandatory, but recommended if you care about
performance.
- You might have some different versions of gcc, SciPy, NumPy, Python installed
on your system, perhaps via Xcode. It is a good idea to use **either** the
MacPorts version of everything **or** some other set of compatible versions
(e.g. provided by Xcode or Fink). The advantages of MacPorts are the
transparency with which everything can be installed and the fact that
packages are updated quite frequently. The following steps describe how to
make sure you are using the MacPorts version of these packages.
- In order to use the MacPorts version of Python, you will probably
need to explicitly select it with ``sudo port select python python27``. The
reason this is necessary is because you may have an Apple-provided Python
(via, for example, an Xcode installation). After performing this step, you
should check that the symbolic link provided by ``which python`` points to
the MacPorts python. For instance, on MacOS X Lion with MacPorts 2.0.3,
the output of ``which python`` is ``/opt/local/bin/python`` and this symbolic
link points to ``/opt/local/bin/python2.7``. When executing ``sudo
port select python python27-apple`` (which you should **not** do), the link
points to ``/usr/bin/python2.7``.
- Similarly, make sure that you are using the MacPorts-provided gcc:
use ``sudo port select gcc`` to see which gcc installs you have on the
system. Then execute for instance ``sudo port select gcc mp-gcc44``
to create a symlink that points to the correct (MacPorts) gcc (version 4.4
in this case).
- At this point, if you have not done so already, it may be a good idea to
close and restart your terminal, to make sure all configuration changes
are properly taken into account.
- Afterwards, please check that the ``scipy`` module that is imported in
Python is the right one (and is a recent one). For instance, ``import
scipy`` followed by ``print scipy.__version__`` and ``print scipy.__path__``
should result in a version number of at least 0.7.0 and a path that starts
with ``/opt/local`` (the path where MacPorts installs its packages). If this
is not the case, then you might have some old installation of ``scipy`` in your
``PYTHONPATH`` so you should edit ``PYTHONPATH`` accordingly.
- Please follow the same procedure with ``numpy``.
- This is covered in the MacPorts installation process, but make sure that
your ``PATH`` environment variable contains ``/opt/local/bin`` and
``/opt/local/sbin`` before any other paths (to ensure that the Python and
gcc binaries that you installed with MacPorts are visible first).
- MacPorts does not create automatically ``nosetests`` and ``pip`` symlinks
pointing to the MacPorts version, so you can add them yourself with
.. code-block:: bash
$ sudo ln -s /opt/local/bin/nosetests-2.7 /opt/local/bin/nosetests
$ sudo ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip
.. _install_others:
Other Platform-specific Installations
=====================================
.. warning::
These instructions are not kept up to date.
NVIDIA Jetson TX1 embedded platform
-----------------------------------
.. code-block:: bash
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libblas-dev git
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git --user # Need Theano 0.8 or more recent
Gentoo
------
Brian Vandenberg emailed `installation instructions on Gentoo
<http://groups.google.com/d/msg/theano-dev/-8WCMn2FMR0/bJPasoZXaqoJ>`_,
focusing on how to install the appropriate dependencies.
Nicolas Pinto provides `ebuild scripts <https://github.com/npinto/sekyfsr-gentoo-overlay/tree/master/sci-libs/Theano>`_.
Docker images
-------------
Builds of Theano are available as `Docker <https://www.docker.com/whatisdocker>`_ images:
`Theano Docker (CPU) <https://hub.docker.com/r/kaixhin/theano/>`_ or `Theano Docker (CUDA) <https://hub.docker.com/r/kaixhin/cuda-theano/>`_.
These are updated on a weekly basis with bleeding-edge builds of Theano. Examples of running bash in a Docker container
are as follows:
.. code-block:: bash
sudo docker run -it kaixhin/theano
sudo docker run -it --device /dev/nvidiactl --device /dev/nvidia-uvm --device /dev/nvidia0 kaixhin/cuda-theano:7.0
For a guide to Docker, see the `official docs <https://docs.docker.com/userguide/>`_. For more details on how to use the
Theano Docker images, including requirements for CUDA support, consult the `source project <https://github.com/Kaixhin/dockerfiles>`_.
差异被折叠。
:orphan:
.. _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>`_.
.. warning::
Installation of Theano on Windows
==================================
Theano is mainly developed and tested on Linux Machines.
These instructions show step-by-step how to install Theano and
required dependencies on a 32- or 64-bit system using freely available
......@@ -26,6 +32,8 @@ C/C++ (for Python 2.7 family this has to be Microsoft Visual Studio
version supporting Visual Studio 2008), and GCC (for non-CUDA C code
generated by Theano).
.. _gpu_windows:
Visual Studio and CUDA
######################
......@@ -37,7 +45,6 @@ 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
......@@ -79,7 +86,7 @@ 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 <http://msinttypes.googlecode.com/svn/trunk/stdint.h>`_ and save it as
`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``.
......@@ -619,6 +626,3 @@ follows:
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:
Requirements
============
.. note::
We only support the installation of the requirements through conda.
.. _BLAS: http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms
.. _Python: http://www.python.org/
Python_ >= 2.6 or >= 3.3
The development package (python-dev or python-devel on most Linux distributions) is recommended (see just below). Python 2.4 was supported up to and including the release 0.6. Python 3 is supported past the 3.3 release.
`NumPy <http://numpy.scipy.org/>`_ >= 1.7.1 < 1.11.1
Earlier versions could work, but we don’t test it.
`SciPy <http://scipy.org>`_ >= 0.11 < 0.17.1
Only currently required for sparse matrix and special functions support, but highly recommended. SciPy >=0.8 could work, but earlier versions have known bugs with sparse matrices.
`BLAS`_ installation (with Level 3 functionality)
* **Recommended**: MKL, which is free through Conda.
* Alternatively, we suggest to install OpenBLAS, with the development headers (``-dev``, ``-devel``, depending on your Linux distribution).
**Optional requirements**
``python-dev``, ``g++`` >= 4.2
**Highly recommended.** Theano can fall back on a NumPy-based Python execution model, but a C compiler allows for vastly faster execution.
`nose <http://nose.readthedocs.io/en/latest/>`_ >= 1.3.0
Recommended, to run Theano's test-suite.
`Sphinx <http://sphinx.pocoo.org/>`_ >= 0.5.1, `pygments <http://pygments.org/>`_
For building the documentation. LaTeX_ and dvipng_ are also necessary for math to show up as images.
`pydot-ng <https://github.com/pydot/pydot-ng>`_
To handle large picture for gif/images.
`NVIDIA CUDA drivers and SDK`_
**Highly recommended** Required for GPU code generation/execution on NVIDIA gpus. See instruction below.
`libgpuarray`_
Required for GPU/CPU code generation on CUDA and OpenCL devices (see: :ref:`gpuarray`.)
Requirements installation through Conda (recommended)
-----------------------------------------------------
Install Miniconda
^^^^^^^^^^^^^^^^^
Follow this `link <http://conda.pydata.org/miniconda.html>`__ to install Miniconda.
.. note::
If you want fast compiled code (recommended), make sure you have g++ (Windows/Linux) or Clang (OS X) installed.
Install requirements and optional packages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
conda install numpy scipy mkl <nose> <sphinx> <pydot-ng>
* Arguments between <...> are optional.
Install and configure the GPU drivers (recommended)
---------------------------------------------------
.. warning::
OpenCL support is still minimal for now.
1. 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.
* Test that it was loaded correctly after the reboot, executing the
command `nvidia-smi` from the command line.
.. note::
Sanity check: The *bin* subfolder should contain an *nvcc*
program. This folder is called the *cuda root* directory.
2. Fix 'lib' path
* Add the 'lib' subdirectory (and/or 'lib64' subdirectory if you have a
64-bit OS) to your ``$LD_LIBRARY_PATH`` environment
variable.
3. Set Theano's config flags
To use the GPU you need to define the *cuda root*. You can do it in one
of the following ways:
* Define a $CUDA_ROOT environment variable to equal the cuda root directory, as in ``CUDA_ROOT=/path/to/cuda/root``, or
* add a ``cuda.root`` flag to :envvar:`THEANO_FLAGS`, as in ``THEANO_FLAGS='cuda.root=/path/to/cuda/root'``, or
* add a [cuda] section to your .theanorc file containing the option ``root = /path/to/cuda/root``.
.. _LaTeX: http://www.latex-project.org/
.. _dvipng: http://savannah.nongnu.org/projects/dvipng/
.. _NVIDIA CUDA drivers and SDK: http://developer.nvidia.com/object/gpucomputing.html
.. _libgpuarray: http://deeplearning.net/software/libgpuarray/installation.html
......@@ -54,6 +54,10 @@ if __name__ == '__main__':
pythonpath = os.pathsep.join([throot, pythonpath])
sys.path[0:0] = [throot] # We must not use os.environ.
# Make sure we don't use gpu to compile documentation
env_th_flags = os.environ.get('THEANO_FLAGS', '')
os.environ['THEANO_FLAGS'] = 'device=cpu,force_device=True'
def call_sphinx(builder, workdir):
import sphinx
if options['--check']:
......@@ -99,3 +103,6 @@ if __name__ == '__main__':
# To go back to the original current directory.
os.chdir(currentdir)
# Reset THEANO_FLAGS
os.environ['THEANO_FLAGS'] = env_th_flags
差异被折叠。
.. _using_gpu:
=============
......@@ -19,11 +18,33 @@ There are two ways currently to use a gpu, one that should support any OpenCL
device as well as NVIDIA cards (:ref:`gpuarray`), and the old backend that
only supports NVIDIA cards (:ref:`cuda`).
Using the GPU in Theano is as simple as setting the ``device`` configuration
flag to ``device=cuda`` (or ``device=gpu`` for the old backend). You can optionally target a specific gpu by specifying
the number of the gpu as in e.g. ``device=cuda2``. You also need to set the
default floating point precision.
For example: ``THEANO_FLAGS='cuda.root=/path/to/cuda/root,device=cuda,floatX=float32'``.
You can also set these options in the .theanorc file's ``[global]`` section:
.. code-block:: cfg
[global]
device = cuda
floatX = float32
.. warning::
If you want to use the new GpuArray backend, make sure to have the
development version of Theano installed. The 0.8.X releases have not
been optimized to work correctly with the new backend.
The old CUDA backend will be deprecated soon, in favor of the new libgpuarray
backend.
.. note::
* If your computer has multiple GPUs and you use ``device=cuda``, the driver
selects the one to use (usually gpu0).
* You can use the program ``nvidia-smi`` to change this policy.
* By default, when ``device`` indicates preference for GPU computations,
Theano will fall back to the CPU if there is a problem with the GPU.
You can use the flag ``force_device=True`` to instead raise an error when
Theano cannot use the GPU.
.. _gpuarray:
......@@ -31,19 +52,32 @@ GpuArray Backend
----------------
If you have not done so already, you will need to install libgpuarray
as well as at least one computing toolkit. Instructions for doing so
are provided at `libgpuarray <http://deeplearning.net/software/libgpuarray/installation.html>`_.
as well as at least one computing toolkit (CUDA or OpenCL). Detailed
instructions to accomplish that are provided at
`libgpuarray <http://deeplearning.net/software/libgpuarray/installation.html>`_.
To install Nvidia's GPU-programming toolchain (CUDA) and configure
Theano to use it, see the installation instructions for
:ref:`Linux <gpu_linux>`, :ref:`MacOS <gpu_macos>` and :ref:`Windows <gpu_windows>`.
While all types of devices are supported if using OpenCL, for the
remainder of this section, whatever compute device you are using will
be referred to as GPU.
.. warning::
If you want to use the new GpuArray backend, make sure to have the
development version of Theano installed. The 0.8.X releases have not
been optimized to work correctly with the new backend.
.. warning::
The backend was designed to support OpenCL, however current support is
incomplete. A lot of very useful ops still do not support it because they
were ported from the old backend with minimal change.
.. _testing_the_gpu:
Testing Theano with GPU
~~~~~~~~~~~~~~~~~~~~~~~
......@@ -150,7 +184,7 @@ the GPU object directly. The following code is modified to do just that.
Here ``tensor.exp(x).transfer(None)`` means "copy ``exp(x)`` to the GPU",
with ``None`` the default GPU context when not explicitly given.
For information on how to set GPU contexts, see :ref:`tut_using_multi_gpu`.
For information on how to set GPU contexts, see :ref:`tut_using_multi_gpu`.
The output is
......@@ -227,10 +261,10 @@ Tips for Improving Performance on GPU
``.theanorc`` file if you plan to do a lot of GPU work.
* The GPU backend supports *float64* variables, but they are still slower
to compute than *float32*. The more *float32*, the better GPU performance
you will get.
* Prefer constructors like ``matrix``, ``vector`` and ``scalar`` (which
you will get.
* Prefer constructors like ``matrix``, ``vector`` and ``scalar`` (which
follow the type set in ``floatX``) to ``dmatrix``, ``dvector`` and
``dscalar``. The latter enforce double precision (*float64* on most
``dscalar``. The latter enforce double precision (*float64* on most
machines), which slows down GPU computations on current hardware.
* Minimize transfers to the GPU device by using ``shared`` variables
to store frequently-accessed data (see :func:`shared()<shared.shared>`).
......
.. include:: css.inc
.. _updating:
Updating Theano
===============
Follow one of these three sections depending on how you installed Theano.
You should update frequently, bugs are fixed on a very regular basis, and features are
added even more frequently!
Stable Installation
-------------------
The following command will update only Theano:
.. raw:: html
<pre><span class="red">&#60;sudo&#62;</span> pip install <span class="blue">&#60;--user&#62;</span> <span class="pink">&#60;--no-deps&#62;</span> theano</pre>
- Use :red:`sudo` for a root installation.
- Use :blue:`user` for a user installation without admin rights. It will install Theano in your local site-packages.
- Use :pink:`no-deps` when you don't want the dependencies of Theano to not be installed through pip. This is important when they have already been installed as system packages.
.. warning::
If you installed NumPy/SciPy with yum/apt-get, updating NumPy/SciPy
with pip/easy_install is not always a good idea. This can make Theano
crash due to problems with BLAS. The versions of
NumPy/SciPy in the distribution are sometimes linked against faster
versions of BLAS. Installing NumPy/SciPy with
yum/apt-get/pip/easy_install won't install the development package
needed to recompile it with the fast version.
To fix a possible crash, you can clear
the Theano cache like this:
.. code-block:: bash
theano-cache clear
Bleeding-Edge Installation
--------------------------
The following command will update your bleeding-edge version of Theano
.. raw:: html
<div style="width:100%"><pre><span class="red">&#60;sudo&#62;</span> pip install <span class="blue">&#60;--user&#62;</span> <span class="pink">&#60;--no-deps&#62;</span> git+https://github.com/Theano/Theano.git#egg=Theano</pre></div>
- Use :red:`sudo` for a root installation.
- Use :blue:`user` for a user installation without admin rights. It will install Theano in your local site-packages.
- Use :pink:`no-deps` when you don't want the dependencies of Theano to not be installed through pip. This is important when they have already been installed as system packages.
.. warning::
If you installed NumPy/SciPy with yum/apt-get, updating NumPy/SciPy
with pip/easy_install is not always a good idea. This can make Theano
crash due to problems with BLAS. The versions of
NumPy/SciPy in the distribution are sometimes linked against faster
versions of BLAS. Installing NumPy/SciPy with
yum/apt-get/pip/easy_install won't install the development package
needed to recompile it with the fast version.
To fix a possible crash, you can clear
the Theano cache like this:
.. code-block:: bash
theano-cache clear
Developer Installation
----------------------
To update your library to the latest revision, change directory (``cd``)
to your ``Theano`` folder and execute the following command:
.. warning::
The following assumes you have knowledge of git and know how to do a rebase.
.. code-block:: bash
git pull --rebase
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论