gpuArray
一种rray stored on GPU
Description
一种gpuArray
对象表示一个数组存储在GPU内存。一种large number of functions in MATLAB®and in other toolboxes supportgpuArray
objects, allowing you to run your code on GPUs with minimal changes to the code. To work withgpuArray
对象,使用任何gpuArray
-enabled MATLAB function such asfft
,,,,mtimes
ormldivide
。找到完整的列表gpuArray
- 在MATLAB和其他工具箱中启用的功能,请参阅GPU-supported functions。有关更多信息,请参阅在GPU上运行MATLAB功能。
如果要从GPU检索数组,例如使用不支持的函数万博1manbetxgpuArray
objects, use the收集
功能。
笔记
You can load MAT files containinggpuArray
data as in-memory arrays when a GPU is not available. AgpuArray
无GPU加载的对象是有限的,您不能将其用于计算。使用一个gpuArray
object loaded without a GPU, retrieve the contents using收集
。
Creation
采用gpuArray
将MATLAB工作区中的数组转换为gpuArray
object. Some MATLAB functions also allow you to creategpuArray
直接对象。有关更多信息,请参阅Establish Arrays on a GPU。
输入参数
对象功能
有几种检查A的特征的方法gpuArray
object. Most behave like the MATLAB functions of the same name.
isgpuarray |
Determine whether input isgpuArray |
存在 |
Determine if gpuArray or CUDAKernel is available on GPU |
isUnderlyingType |
Determine whether input has specified underlying data type |
ndims |
Number of array dimensions |
尺寸 |
一种rray size |
underlyingType |
确定数组行为的基础数据类型 |
几个MATLAB工具箱包括带有内置的功能gpuArray
support. To view lists of all functions in these toolboxes that supportgpuArray
对象,使用下表中的链接。带有信息指示器的列表中的功能具有限制或使用指示说明特定于在GPU上运行该功能的情况。您可以在功能参考页面的“扩展功能”部分中检查使用说明和限制。有关个人更新的信息gpuArray
-enabled functions, see the release notes.
工具箱名称 | List of Functions withgpuArray 万博1manbetx |
GPU-Specific Documentation |
---|---|---|
MATLAB | 职能withgpuArray 万博1manbetx |
|
Statistics and Machine Learning Toolbox™ | 职能withgpuArray 万博1manbetx(统计和机器学习工具箱) |
分析和建模GPU(统计和机器学习工具箱) |
图像处理工具箱™ | 职能withgpuArray 万博1manbetx(Image Processing Toolbox) |
GPU Computing(Image Processing Toolbox) |
Deep Learning Toolbox™ | 职能with *(也可以看看Deep Learning with GPUs) |
Scale Up Deep Learning in Parallel, on GPUs, and in the Cloud(Deep Learning Toolbox) 在多个GPU上使用MATLAB进行深度学习(Deep Learning Toolbox) |
计算机视觉工具箱™ | 职能withgpuArray 万博1manbetx(计算机视觉工具箱) |
GPU Code Generation and Acceleration(计算机视觉工具箱) |
Communications Toolbox™ | 职能withgpuArray 万博1manbetx(Communications Toolbox) |
代码生成和加速支持万博1manbetx(Communications Toolbox) |
Signal Processing Toolbox™ | 职能withgpuArray 万博1manbetx(Signal Processing Toolbox) |
Code Generation and GPU Support(Signal Processing Toolbox) |
一种udio Toolbox™ | 职能withgpuArray 万博1manbetx(Audio Toolbox) |
Code Generation and GPU Support(Audio Toolbox) |
Wavelet Toolbox™ | 职能withgpuArray 万博1manbetx(Wavelet Toolbox) |
Code Generation and GPU Support(Wavelet Toolbox) |
曲线拟合工具箱™ | 职能withgpuArray 万博1manbetx(曲线拟合工具箱) |
You can browsegpuArray
-万博1manbetx 支持功能from all MathWorks®products at the following link:gpuArray
-万博1manbetx 支持功能。一种lternatively, you can filter by product. On theHelp酒吧,单击职能。In the function list, browse the left pane to select a product, for example, MATLAB. At the bottom of the left pane, selectGPU Arrays。如果您选择没有的产品gpuArray
- 启用功能,然后GPU Arraysfilter is not available.
例子
Tips
If you need better performance, or if a function is not available on the GPU,
gpuArray
supports the following options:预编译和运行纯粹的元素代码
gpuArray
objects, use thearrayfun
功能。To run C++ code containing CUDA®device code or library calls, use a MEX function. For more information, seeRun MEX-Functions Containing CUDA Code。
要运行用CUDA C ++编写的现有GPU内核,请使用MATLAB CUDAKERNEL接口。有关更多信息,请参阅Run CUDA or PTX Code on GPU。
To generate CUDA code from MATLAB code, use GPU Coder™. For more information, seeGet Started with GPU Coder(GPU Coder)。
You can control the random number stream on the GPU using
gpurng
。None of the following can exceed
intmax(“int32”)
:The number of elements of a dense array.
稀疏阵列的非零元素的数量。
The size in any given dimension. For example,
零(0,3e9,"gpuArray")
不允许。
备择方案
You can also create agpuArray
object using some MATLAB functions by specifying agpuArray
output. The following table lists the MATLAB functions that enable you to creategpuArray
直接对象。有关更多信息,请参见功能参考页面的扩展功能部分。