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 the ComputeCapability property in the output of the gpuDeviceTable and gpuDevice functions. 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.5, cc3.7)Kepler (cc3.0, cc3.2)Fermi (cc2.x)Tesla (cc1.3)CUDA® Toolkit Version
R2021a

   11.0
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

  • – 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 generate CUDA kernel objects from CU code or use GPU Coder™ to compile CUDA compatible source code, libraries, and executables, you must install a CUDA Toolkit. The CUDA Toolkit contains CUDA libraries and tools for compilation. You do not need the toolkit to run MATLAB functions on a GPU or to generate CUDA enabled MEX functions.

TaskRequirements
  • Use gpuArray and GPU-enabled MATLAB functions.

  • Compile CUDA enabled MEX-functions using GPU Coder or mexcuda.

Get the latest graphics driver at NVIDIA Driver Downloads.

You do not need the CUDA Toolkit as well.

  • Create CUDA kernel objects from CU code.*

  • Compile CUDA compatible source code, libraries, and executables using GPU Coder.

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

* To create CUDA kernel objects in MATLAB, you must have both the CU file and the corresponding PTX file. Compiling the PTX file from the CU file requires the CUDA toolkit. If you already have the corresponding PTX file, you do not need the toolkit.

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.

The toolkit version that you need depends on the version of MATLAB you are using. Check which version of the toolkit is compatible with your version of MATLAB version in the table in Supported GPUs. Recommended best practice is to use the latest version of your supported toolkit, including any updates and patches from NVIDIA.

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.enableCUDAForwardCompatibility. 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. On the client, you can use setenv to set environment variables. You can then copy environment variables from the client to the workers so that the workers perform computations in the same way as the client. For more information, use Set Environment Variables on Workers.

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). On the client, you can use setenv to set environment variables. You can then copy environment variables from the client to the workers so that the workers perform computations in the same way as the client. For more information, use Set Environment Variables on Workers.

Related Topics

External Websites