query or select a gpu device -凯发k8网页登录
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
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 indx
)indx
. 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 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
you can identify, select, reset, or wait for a gpu device using the following functions:
number of gpu devices present | |
reset gpu device and clear its memory | |
wait for gpu calculation to complete |
the following functions are also available:
parallel.gpu.gpudevice.isavailable(indx) | returns logical 1 or true if the gpu
specified by index indx is supported and capable of being
selected. indx can be an integer or a vector of integers; the
default index is the current device. |
parallel.gpu.gpudevice.getdevice(indx) | 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