parallel.gpu.enableCUDAForwardCompatibility
Query and set forward compatibility for GPU devices
Syntax
Description
returnstf
= parallel.gpu.enableCUDAForwardCompatibility()true
if forward compatibility for GPU devices is enabled andfalse
otherwise. The default isfalse
.
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.
parallel.gpu.enableCUDAForwardCompatibility(
enables or disables forward compatibility for GPU devices.tf
)tf
must betrue
(1
) orfalse
(0
).
If you enable forward compatibility, 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 several minutes.
Enabling forward compatibility is not persistent between MATLAB sessions.
Caution
Enabling forward compatibility can result in wrong answers and unexpected behavior during GPU computations.
For more information, seeForward Compatibility For GPU Devices.
Examples
Input Arguments
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 the end of this section.
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
to1
. 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 usesetenv
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, useSet 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 of536870912
(512 MB). On the client, you can usesetenv
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, useSet Environment Variables on Workers.