Main Content

GPU Computing in MATLAB

Accelerate your code using basic GPU computing

To speed up your code, first try profiling and vectorizing it. For information, see Performance 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 use gpuArray to transfer input data to the GPU, and call gather to retrieve the output data from the GPU. To get started with GPU computing, see Run MATLAB Functions on a GPU.

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


expand all

gpuArrayArray stored on GPU
gatherTransfer distributed array, Composite array or gpuArray to local workspace
gpuDeviceQuery or select a GPU device
GPUDeviceManagerManager for GPU Devices
gpuDeviceCountNumber of GPU devices present
gpuDeviceTableTable of properties of GPU devices
wait (GPUDevice)Wait for GPU calculation to complete
gputimeitTime required to run function on GPU
existsOnGPUDetermine if gpuArray or CUDAKernel is available on GPU
isgpuarrayDetermine whether input is gpuArray
arrayfunApply function to each element of array on GPU
pagefunApply function to each page of distributed or GPU array
gpurngControl random number generation for GPU calculations
resetReset GPU device and clear its memory
parallel.gpu.RandStreamRandom number stream on a GPU
parallel.gpu.enableCUDAForwardCompatibilityQuery and set forward compatibility for GPU devices


Run MATLAB Code on GPU

Improve Performance on GPU

Learn More