Main Content

parallel.gpu.enableCUDAForwardCompatibility

Query and set forward compatibility for GPU devices

    Description

    tf = parallel.gpu.enableCUDAForwardCompatibility() returns true if forward compatibility for GPU devices is enabled and false otherwise. The default is false.

    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(tf)enables or disables forward compatibility for GPU devices. tf must be true (1) or false (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, see Forward Compatibility for GPU Devices.

    Examples

    collapse all

    If you have a GPU with an architecture that was released after the version of MATLAB you are using, by default, you cannot use that GPU to perform computations in MATLAB. To use that GPU in MATLAB, enable forward compatibility for GPU devices.

    Check whether forward compatibility is enabled.

    tf = parallel.gpu.enableCUDAForwardCompatibility()
    tf = 
       0
    

    Enable forward compatibility.

    parallel.gpu.enableCUDAForwardCompatibility(1)

    Select and use the GPU device.

    gpuDevice(2);
    A = ones(100,'gpuArray');

    The first time you access the GPU from MATLAB, the CUDA driver recompiles the libraries. Recompilation can take several minutes.

    Input Arguments

    collapse all

    Forward compatibility status to set, specified as a numeric or logical 1 (true) or 0 (false).

    Example: 0

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

    Introduced in R2020b