Introduction to GPU Computing with MATLAB
GPU computing is a widely adopted technology that uses the power of GPUs to accelerate computationally intensive workflows. Since 2010, Parallel Computing Toolbox has provided GPU Computing support for MATLAB.
Although GPUs were originally developed for graphics rendering, they are now used generally to accelerate applications in fields such as scientific computing, engineering, artificial intelligence, and financial analysis.
Using Parallel Computing Toolbox, you can leverage NVIDIA GPUs to accelerate your application directly from MATLAB.
MATLAB provides a direct interface for accelerating computationally intensive workflows on GPUs for over 500 functions.
Using these supported functions, you can execute your code on a GPU without needing any CUDA programming experience. For computationally intensive problems, it’s possible to achieve significant speedup making only a few changes to your existing code.
With GPU support in Parallel Computing Toolbox, it’s easy to determine if you can use a GPU to speed up your application.
If your code includes GPU supported functions, converting your inputs to GPU arrays will automatically execute those functions on your GPU. MATLAB automatically handles GPU resource allocation, so you can focus on your application without having to learn any low-level GPU computing tools.
If your code includes GPU supported functions, converting your inputs to GPU arrays will automatically execute those functions on your GPU. MATLAB automatically handles GPU resource allocation, so you can focus on your application without having to learn any low-level GPU computing tools.
You can use gpuBench from MathWorks File Exchange to compare performance of supported GPUs using standard numerical benchmarks in MATLAB.
Many MATLAB functions such as the trainNetwork function use any compatible GPUs by default. To train your model on multiple GPUs, you can simply change a training option directly in MATLAB.
If you don’t have access to a GPU on your laptop or workstation, you can leverage a MATLAB Reference Architecture to use one or more GPUs with a MATLAB desktop in the cloud.
You can also leverage the MATLAB Deep Learning Container for NVIDIA GPU Cloud which supports NVIDIA DGX and other platforms that support Docker.
If you have many GPU applications to run or need to scale beyond a single machine with GPUs, you can use MATLAB Parallel Server to extend your workflow to a cluster with GPUs. If you don’t already have access to a GPU cluster, you can leverage MathWorks Cloud Center or a MATLAB Parallel Server Reference Architecture.
Parallel Computing Toolbox provides additional features for working directly with CUDA code. The mexcuda function compiles CUDA code into a MEX-file that can be called directly in MATLAB as a function.
Conversely, after writing your MATLAB code, you can generate and deploy ready-to-use CUDA code with GPU Coder. The generated code is optimized to call standard CUDA libraries and can be integrated and deployed directly onto NVIDIA GPUs.
To learn more about how to take full advantage of your GPU in MATLAB, explore the GPU computing solutions page.
You can also explore the MathWorks documentation for a complete list of functions with GPU support and more examples.
Additional Resources:
- Explore MATLAB GPU Computing Support for NVIDIA CUDA-Enabled GPUs: https://bit.ly/2Nb7Olf
Join us on Facebook Group:
https://www.facebook.com/groups/matlabcodes
No comments