@@ -12,12 +12,15 @@ and their use for intensive parallel computation purposes, see `GPGPU
...
@@ -12,12 +12,15 @@ and their use for intensive parallel computation purposes, see `GPGPU
One of Theano's design goals is to specify computations at an abstract
One of Theano's design goals is to specify computations at an abstract
level, so that the internal function compiler has a lot of flexibility
level, so that the internal function compiler has a lot of flexibility
about how to carry out those computations. One of the ways we take
about how to carry out those computations. One of the ways we take
advantage of this flexibility is in carrying out calculations on an
advantage of this flexibility is in carrying out calculations on a
Nvidia graphics card when the device present in the computer is
graphics card.
CUDA-enabled.
Setting Up CUDA
There are two ways currently to use a gpu, one of which only supports NVIDIA cards (:ref:`cuda`) and the other, in development, that should support any OpenCL device as well as NVIDIA cards (:ref:`gpuarray`).
----------------
.. _cuda:
CUDA backend
------------
If you have not done so already, you will need to install Nvidia's
If you have not done so already, you will need to install Nvidia's
GPU-programming toolchain (CUDA) and configure Theano to use it.
GPU-programming toolchain (CUDA) and configure Theano to use it.
...
@@ -420,6 +423,247 @@ What can be done to further increase the speed of the GPU version? Put your idea
...
@@ -420,6 +423,247 @@ What can be done to further increase the speed of the GPU version? Put your idea
:download:`Solution<using_gpu_solution_1.py>`
:download:`Solution<using_gpu_solution_1.py>`
-------------------------------------------
.. _gpuarray:
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>`_.
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.
Testing Theano with GPU
-----------------------
To see if your GPU is being used, cut and paste the following program
into a file and run it.
.. code-block:: python
from theano import function, config, shared, tensor, sandbox
import numpy
import time
vlen = 10 * 30 * 768 # 10 x #cores x # threads per core
iters = 1000
rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))