@@ -76,13 +76,13 @@ The following libraries and software are optional:
Linux
-----
.. _linux_basic:
Alternative installation on Ubuntu with PPA
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Benjamin J. McCann provides `installation documentation <http://www.benmccann.com/dev-blog/installing-cuda-and-theano/>`_ for Ubuntu 11.04 with CUDA 4.0 PPA.
.. _linux_basic:
Basic user install instructions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
@@ -357,6 +357,67 @@ correctly (for example, for MKL this might be ``-lmkl -lguide -lpthread`` or
This might be just a problem with the way Theano passes compilation
arguments to gcc, but the problem is not fixed yet.
.. _gpu_linux:
Using the GPU
~~~~~~~~~~~~~
The first thing you'll need for Theano to use your GPU is Nvidia's
GPU-programming toolchain. You should install at least the CUDA driver and the CUDA Toolkit, as
`described here <http://www.nvidia.com/object/cuda_get.html>`_. The CUDA
Toolkit installs a folder on your computer with subfolders *bin*, *lib*,
*include*, and some more too. (Sanity check: The *bin* subfolder should contain an *nvcc*
program which is the compiler for GPU code.) This folder is called the *cuda
root* directory.
You must also add the 'lib' subdirectory (and/or 'lib64' subdirectory if you have a 64-bit Linux
computer) to your ``$LD_LIBRARY_PATH`` environment variable.
You must then tell Theano where the CUDA root folder is, and there are three ways
to do it.
Any one of them is enough.
* 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``.
Once that is done, the only thing left is to change the ``device`` option to name the GPU device in your
computer, and set the default floating point computations to float32.
For example: ``THEANO_FLAGS='cuda.root=/path/to/cuda/root,device=gpu,floatX=float32'``.
You can also set these options in the .theanorc file's ``[global]`` section:
.. code-block:: cfg
[global]
device = gpu
floatX = float32
Note that:
* If your computer has multiple GPUs and you use 'device=gpu', the driver
selects the one to use (usually gpu0).
* You can use the program nvida-smi to change this policy.
* You can choose one specific GPU by specifying 'device=gpuX', with X the
the corresponding GPU index (0, 1, 2, ...)
* 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.
Once your setup is complete, head to :ref:`using_gpu` to find how to verify
everything is working properly.
.. note::
There is a compatibility issue affecting some Ubuntu 9.10 users, and probably anyone using
CUDA 2.3 with gcc-4.4. Symptom: errors about "__sync_fetch_and_add" being undefined.
@@ -14,55 +14,13 @@ there is a CUDA-enabled device in your computer.
Setting up CUDA
----------------
The first thing you'll need for Theano to use your GPU is Nvidia's
GPU-programming toolchain. You should install at least the CUDA driver and the CUDA Toolkit, as
`described here <http://www.nvidia.com/object/cuda_get.html>`_. The CUDA
Toolkit installs a folder on your computer with subfolders *bin*, *lib*,
*include*, and some more too. (Sanity check: The *bin* subfolder should contain an *nvcc*
program which is the compiler for GPU code.) This folder is called the *cuda
root* directory.
On Linux or OS X >= 10.4, you must add the 'lib' subdirectory (and/or 'lib64' subdirectory if you have a 64-bit Linux
computer) to your ``$LD_LIBRARY_PATH`` environment variable.
Making Theano use CUDA
----------------------
You must tell Theano where the cuda root folder is, and there are three ways
to do it.
Any one of them is enough.
* 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``.
Once that is done, the only thing left is to change the ``device`` option to name the GPU device in your
computer.
For example: ``THEANO_FLAGS='cuda.root=/path/to/cuda/root,device=gpu'``.
You can also set the device option in the .theanorc file's ``[global]`` section.
* If your computer has multiple gpu and use 'device=gpu', the driver select the one to use (normally gpu0)
* You can use the program nvida-smi to change that policy.
* You can choose one specific gpu by giving device the one of those values: gpu0, gpu1, gpu2, or gpu3.
* If you have more than 4 devices you are very lucky but you'll have to modify theano's *configdefaults.py* file and define more gpu devices to choose from.
* Using the 'device=gpu*' theano flag make theano fall back to the cpu if their is a problem with the gpu.
You can use the flag 'force_device=True' to have theano raise an error when we can't use the gpu.
.. note::
There is a compatibility issue affecting some Ubuntu 9.10 users, and probably anyone using
CUDA 2.3 with gcc-4.4. Symptom: errors about "__sync_fetch_and_add" being undefined.