Main Content

GPU Computing inMATLAB

Accelerate your code using basic GPU computing

To speed up your code, first try profiling and vectorizing it. For information, seePerformance and Memory. After profiling and vectorizing, you can also try using your computer’s GPU to speed up your calculations. If all the functions that you want to use are supported on the GPU, you can simply usegpuArrayto transfer input data to the GPU, and callgatherto retrieve the output data from the GPU. To get started with GPU computing, seeRun MATLAB Functions on a GPU.

For deep learning, MATLAB®provides automatic parallel support for multiple GPUs. SeeDeep Learning with MATLAB on Multiple GPUs(Deep Learning Toolbox).

Functions

expand all

gpuArray Array stored on GPU
gather Transfer distributed array or gpuArray to local workspace
gpuDevice Query or select a GPU device
GPUDeviceManager Manager for GPU Devices
gpuDeviceCount Number of GPU devices present
gpuDeviceTable Table of properties of GPU devices
reset Reset GPU device and clear its memory
wait (GPUDevice) 等待GPU计算完成
gputimeit Time required to run function on GPU
existsOnGPU Determine if gpuArray or CUDAKernel is available on GPU
isgpuarray Determine whether input isgpuArray
arrayfun Apply function to each element of array on GPU
pagefun Apply function to each page of distributed or GPU array
gpurng Control random number generation for GPU calculations
parallel.gpu.RandStream Random number stream on a GPU
parallel.gpu.enableCUDAForwardCompatibility Query and set forward compatibility for GPU devices

Topics

RunMATLABCode on GPU

Improve Performance on GPU

Learn More