array stored on gpu -凯发k8网页登录
array stored on gpu
description
a gpuarray
object represents an array stored in gpu memory. a
large number of functions in matlab® and in other toolboxes support gpuarray
objects, allowing you to run your code on gpus
with minimal changes to the code. to work with gpuarray
objects, use any
gpuarray
-enabled matlab function such as fft
, mtimes
or
mldivide
. to find a full list of gpuarray
-enabled functions in
matlab and in other toolboxes, see . for more information, see run matlab functions on a gpu.
if you want to retrieve the array from the gpu, for example when using a function that
does not support gpuarray
objects, use the function.
note
you can load mat files containing gpuarray
data as in-memory arrays when a gpu is not
available. a gpuarray
object loaded without a gpu is limited and you cannot use it for
computations. to use a gpuarray
object loaded without a gpu, retrieve the contents using .
creation
use gpuarray
to convert an array in the matlab workspace into a gpuarray
object. some matlab functions also allow you to create gpuarray
objects directly.
for more information, see .
syntax
input arguments
object functions
apply function to each element of array on gpu | |
transfer distributed array, composite array or gpuarray to local workspace | |
apply function to each page of distributed or gpu array |
there are several methods for examining the characteristics of a
gpuarray
object. most behave like the matlab functions of the same name.
determine whether input is gpuarray
| |
determine if gpuarray or cudakernel is available on gpu | |
determine whether input has specified underlying data type | |
number of array dimensions | |
array size | |
type of underlying data determining array behavior |
several matlab toolboxes include functions with gpuarray
support. to view
lists of all functions in these toolboxes that support gpuarray
objects, use
the links in the following table. functions in the lists with information indicators have
limitations or usage notes specific to running the function on a gpu. you can check the usage
notes and limitations in the extended capabilities section of the function reference page. for
information about updates to individual gpuarray
-enabled functions, see the
release notes.
toolbox name | list of functions with gpuarray support | gpu-specific documentation |
---|---|---|
matlab | ||
statistics and machine learning toolbox™ | functions with
gpuarray support (statistics and machine learning toolbox) | analyze and model data on gpu (statistics and machine learning toolbox) |
image processing toolbox™ | (image processing toolbox) | (image processing toolbox) |
deep learning toolbox™ | (deep learning toolbox) *(see also deep learning with gpus) | (deep learning toolbox) (deep learning toolbox) |
computer vision toolbox™ | (computer vision toolbox) | (computer vision toolbox) |
communications toolbox™ | (communications toolbox) | (communications toolbox) |
signal processing toolbox™ | (signal processing toolbox) | code generation and gpu support (signal processing toolbox) |
audio toolbox™ | (audio toolbox) | code generation and gpu support (audio toolbox) |
wavelet toolbox™ | (wavelet toolbox) | code generation and gpu support (wavelet toolbox) |
curve fitting toolbox™ | (curve fitting toolbox) |
for a list of functions with gpuarray
support in all
mathworks® products, see . alternatively, you can
filter by product. on the help bar, click functions.
in the function list, browse the left pane to select a product, for example, matlab. at the bottom of the left pane, select gpu arrays. if you
select a product that does not have gpuarray
-enabled functions, then the
gpu arrays filter is not available.
examples
tips
if you need better performance, or if a function is not available on the gpu,
gpuarray
supports the following options:to precompile and run purely element-wise code on
gpuarray
objects, use the function.to run c code containing cuda® device code or library calls, use a mex function. for more information, see .
to run existing gpu kernels written in cuda c , use the matlab cudakernel interface. for more information, see .
to generate cuda code from matlab code, use gpu coder™. for more information, see get started with gpu coder (gpu coder).
you can control the random number stream on the gpu using .
none of the following can exceed
intmax("int32")
:the number of elements of a dense array.
the number of nonzero elements of a sparse array.
the size in any given dimension. for example,
zeros(0,3e9,"gpuarray")
is not allowed.
alternatives
you can also create a gpuarray
object using some matlab functions by specifying a gpuarray
output. the following
table lists the matlab functions that enable you to create gpuarray
objects
directly. for more information, see the extended capabilities section of the function
reference page.
(___,"gpuarray") | (___,"gpuarray") |
(___,"gpuarray") | (___,"gpuarray") |
(___,"gpuarray") | gpuarray. |
(___,"gpuarray") | gpuarray. |
(___,"gpuarray") | gpuarray. |
(___,"gpuarray") | gpuarray. |
(___,"gpuarray") | gpuarray. |
(___,"gpuarray") |
extended capabilities
version history
introduced in r2010b