Main Content

GPU Support by Release

To use your GPU with MATLAB®, you must install a recent graphics driver. Best practice is to ensure you have the latest driver for your device. Installing the driver is sufficient for most uses of GPUs in MATLAB, including gpuArray and GPU-enabled MATLAB functions. You can download the latest drivers for your GPU device at NVIDIA Driver Downloads.

Supported GPUs

To see support for NVIDIA® GPU architectures by MATLAB release, consult the following table.

The cc numbers show the compute capability of the GPU architecture. To check your GPU compute capability, see ComputeCapability in the output of the gpuDevice function. Alternatively, see CUDA GPUs (NVIDIA).

MATLAB ReleaseAmpere (cc8.x)Turing (cc7.5)Volta (cc7.0, cc7.2)Pascal (cc6.x)Maxwell (cc5.x)Kepler (cc3.x)Fermi (cc2.x)Tesla (cc1.3)CUDA® Toolkit Version
R2020b

  10.2
R2020a

  10.1
R2019b

  10.1
R2019a

  10.0
R2018b

  9.1
R2018a

  9.0
R2017b

 8.0
R2017a

 8.0
R2016b

 7.5
R2016a

 7.5
R2015b

 7.0
R2015a

 6.5
R2014b

 6.0
R2014a

5.5
R2013b

5.0
R2013a

5.0
R2012b

4.2
R2012a

4.0
R2011b

4.0
R2011a

3.2
R2010b

3.1

  • – Built-in binary support.

  • – Support for Kepler and Maxwell GPU architectures will be removed in a future release. At that time, using a GPU with MATLAB will require a GPU device with compute capability 6.0 or greater. MATLAB generates a warning the first time you use a Kepler or Maxwell GPU.

  • – Supported via forward compatibility. Optimized device libraries must be compiled at runtime from an unoptimized version. Support can be limited and you might see errors and unexpected behaviour. For more information, see Forward Compatibility for GPU Devices.

  • – By default, this architecture is not supported. You can enable support by enabling forward compatibility for GPU devices. You might see errors and unexpected behaviour. For more information, see Forward Compatibility for GPU Devices.

CUDA Toolkit

If you want to use CUDA kernel objects or use GPU Coder, you must install a CUDA Toolkit. The CUDA Toolkit contains CUDA libraries and tools for compilation.

TaskRequirements

Use gpuArray and GPU-enabled MATLAB functions, or create CUDA enabled MEX-functions.

Get the latest graphics driver at NVIDIA Driver Downloads.

You do not need the CUDA Toolkit as well.

Create and use CUDA kernel objects or use GPU Coder.

Install the version of the CUDA Toolkit supported by your MATLAB release.

For more information about generating CUDA code in MATLAB, see Run MEX-Functions Containing CUDA Code and Run CUDA or PTX Code on GPU. Not all compilers supported by the CUDA Toolkit are supported in MATLAB.

For more information about the CUDA Toolkit and to download your supported version, see CUDA Toolkit Archive (NVIDIA).

Forward Compatibility for GPU Devices

Note

Starting in R2020b, forward compatibility for GPU devices is disabled by default.

In R2020a and earlier releases, you cannot disable forward compatibility for GPU devices.

Forward compatibility allows you to use a GPU device with an architecture that was released after your version of MATLAB was built, by recompiling the device libraries at runtime.

When forward compatibility is enabled, the CUDA driver recompiles the GPU libraries the first time you access a device with an architecture newer than your MATLAB version. Recompilation can take up to an hour. Increase the CUDA cache size to prevent a recurrence of this delay. For instructions, see Increase the CUDA Cache Size.

When forward compatibility is disabled, you cannot perform computations using a GPU device with an architecture that was released after the version of MATLAB you are using was built. You must enable forward compatibility if you want to use this GPU device in MATLAB.

Caution

Enabling forward compatibility can result in wrong answers and unexpected behavior during GPU computations.

The degree of success of recompilation of device libraries can vary depending on the device architecture and the CUDA version used by MATLAB. In some cases, forward compatibility does not work as expected and recompilation of the libraries results in errors.

For example, forward compatibility from CUDA version 10.0–10.2 (MATLAB versions R2019a, R2019b, R2020a, and R2020b) to Ampere (compute capability 8.x) has only limited functionality.

You can enable forward compatibility for GPU devices using the following methods.

  • Use the function parallel.gpu.enableCUDAForwardCompatiblity. Enabling forward compatibility using this method is not persistent between MATLAB sessions.

  • Set the environment variable MW_CUDA_FORWARD_COMPATIBILITY to 1. This can preserve the forward compatibility between MATLAB sessions. If you change the environment variable while MATLAB is running, you must restart MATLAB to see the effect. For help setting an environment variable, see this example: Set the MATLABPATH Environment Variable

Increase the CUDA Cache Size

If your GPU architecture does not have built-in binary support in your MATLAB release, the graphics driver must compile and cache the GPU libraries. This process can take up to an hour the first time you access the GPU from MATLAB. To increase the CUDA cache size to prevent a recurrence of this delay, set the environment variable CUDA_CACHE_MAXSIZE to a minimum of 536870912 (512 MB). For help setting an environment variable, see this example: Set the MATLABPATH Environment Variable.

Related Topics

External Websites