gpuDevice
Query or select a GPU device
Description
A GPUDevice object represents a graphic processing unit (GPU)
in your computer. You can use the GPU to run MATLAB® code that supports gpuArray variables or execute CUDA® kernels using CUDAKernel objects.
You can use a GPUDevice object to inspect the properties of your GPU
device, reset the GPU device, or wait for your GPU to finish executing a computation. To
obtain a GPUDevice object, use the gpuDevice function.
You can also select or deselect your GPU device using the gpuDevice
function. If you have access to multiple GPUs, use the gpuDevice function
to choose a specific GPU device on which to execute your code.
You do not need to use a GPUDevice object to run functions on a GPU.
For more information on how to use GPU-enabled functions, see Run MATLAB Functions on a GPU.
Creation
Description
gpuDevice displays the properties of the currently selected GPU
device. If there is no currently selected device, gpuDevice selects the
default device without clearing it. Use this syntax when you want to inspect the
properties of your GPU device.
D = gpuDevice returns a GPUDevice object
representing the currently selected device. If there is no currently selected device,
gpuDevice selects the default device and returns a
GPUDevice object representing that device without clearing it.
D = gpuDevice( selects the GPU device
specified by index ind)ind. If the specified GPU device is not supported,
an error occurs. This syntax resets the specified device and clears its memory, even if
the device is already currently selected (equivalent to the reset function). All workspace variables representing
gpuArray or CUDAKernel variables are now invalid
and must be cleared from the workspace or redefined.
gpuDevice([]), with an empty argument (as opposed to no
argument), deselects the GPU device and clears its memory of gpuArray
and CUDAKernel variables. This syntax leaves no GPU device selected as
the current device.
Input Arguments
Properties
Object Functions
reset | Reset GPU device and clear its memory |
wait (GPUDevice) | Wait for GPU calculation to complete |
The following functions are also available:
parallel.gpu.GPUDevice.isAvailable(ind) | Returns logical 1 or true if the GPU
specified by index ind is supported and capable of being
selected. ind can be an integer or a vector of integers; the
default index is the current device. |
parallel.gpu.GPUDevice.getDevice(ind) | Returns a GPUDevice object without selecting it. |
For a complete list of functions, use the methods function on the
GPUDevice object:
methods('parallel.gpu.GPUDevice')You can get help on any of the object functions with the following command:
help parallel.gpu.GPUDevice.functionname
where functionname is the name of the function. For example, to
get help on isAvailable, type:
help parallel.gpu.GPUDevice.isAvailable
Examples
Extended Capabilities
Version History
Introduced in R2010bSee Also
gpuArray | gpuDeviceTable | gpuDeviceCount | canUseGPU | validateGPU | arrayfun | reset | wait (GPUDevice) | GPUDeviceManager
