Main Content

validateGPU

Validate GPU devices

Since R2024b

    Description

    validateGPU validates the currently selected GPU device. If no GPU device is selected, then the function validates the default device.

    example

    validateGPU("all") validates all GPU devices detected in your system.

    example

    validateGPU(ind) validates the GPU devices specified by indices ind.

    Tip

    Validating your GPU device is not required. Use the validateGPU function to diagnose problems with your GPU setup.

    example

    Examples

    collapse all

    Validate the currently selected GPU device. If no GPU device is selected, the function validates the default device. The validateGPU function prints the validation steps performed and an indication of whether each step passed, failed, or was skipped. If a validation step fails, the function prints a diagnostic message.

    validateGPU
    # Beginning GPU validation
    # Performing system validation
    #    CUDA-supported platform .................................................PASSED
    #    CUDA-enabled graphics driver exists .....................................PASSED
    #        Version: 537.70
    #    CUDA-enabled graphics driver load .......................................PASSED
    #    CUDA environment variables ..............................................PASSED
    #    CUDA device count .......................................................PASSED
    #        Found 2 devices.
    #    GPU libraries load ......................................................PASSED
    # 
    # Performing device validation for device index 1
    #    Device exists ...........................................................PASSED
    #        NVIDIA RTX A5000
    #    Device supported ........................................................PASSED
    #    Device available ........................................................PASSED
    #        Device is in 'Default' compute mode.
    #    Device selectable .......................................................PASSED
    #    Device memory allocation ................................................PASSED
    #    Device kernel launch ....................................................PASSED
    # 
    # Finished GPU validation with no failures.
    

    Validate all GPU devices present in your system. The validateGPU function performs a series of system validation checks once, and then a series of device validation steps once for each device detected.

    validateGPU("all")
    # Beginning GPU validation
    # Performing system validation
    #    CUDA-supported platform .................................................PASSED
    #    CUDA-enabled graphics driver exists .....................................PASSED
    #        Version: 537.70
    #    CUDA-enabled graphics driver load .......................................PASSED
    #    CUDA environment variables ..............................................PASSED
    #    CUDA device count .......................................................PASSED
    #        Found 2 devices.
    #    GPU libraries load ......................................................PASSED
    # 
    # Performing device validation for device index 1
    #    Device exists ...........................................................PASSED
    #        NVIDIA RTX A5000
    #    Device supported ........................................................PASSED
    #    Device available ........................................................PASSED
    #        Device is in 'Default' compute mode.
    #    Device selectable .......................................................PASSED
    #    Device memory allocation ................................................PASSED
    #    Device kernel launch ....................................................PASSED
    # 
    # Performing device validation for device index 2
    #    Device exists ...........................................................PASSED
    #        Quadro P620
    #    Device supported ........................................................PASSED
    #    Device available ........................................................PASSED
    #        Device is in 'Default' compute mode.
    #    Device selectable .......................................................PASSED
    #    Device memory allocation ................................................PASSED
    #    Device kernel launch ....................................................PASSED
    # 
    # Finished GPU validation with no failures.
    

    Validate the GPU device with index 2.

    validateGPU(2)
    # Beginning GPU validation
    # Performing system validation
    #    CUDA-supported platform .................................................PASSED
    #    CUDA-enabled graphics driver exists .....................................PASSED
    #        Version: 537.70
    #    CUDA-enabled graphics driver load .......................................PASSED
    #    CUDA environment variables ..............................................PASSED
    #    CUDA device count .......................................................PASSED
    #        Found 2 devices.
    #    GPU libraries load ......................................................PASSED
    # 
    # Performing device validation for device index 2
    #    Device exists ...........................................................PASSED
    #        Quadro P620
    #    Device supported ........................................................PASSED
    #    Device available ........................................................PASSED
    #        Device is in 'Default' compute mode.
    #    Device selectable .......................................................PASSED
    #    Device memory allocation ................................................PASSED
    #    Device kernel launch ....................................................PASSED
    # 
    # Finished GPU validation with no failures.
    

    If you have multiple GPU devices, then you can validate several using a single call to validateGPU by passing a vector of device indices as input. For example, to validate GPU devices 1 and 2, call validateGPU([1 2]).

    Input Arguments

    collapse all

    Indices of GPU devices to validate, specified as an integer or vector of integers in the range 1 to gpuDeviceCount.

    Example: 2

    Example: [1 3]

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

    Tips

    • To validate remote GPUs, start a parallel pool using your cluster with as many workers as there are GPUs, then call validateGPU inside an spmd block.

      cluster = parcluster("myRemoteGPUCluster"); 
      pool = parpool(cluster,numGPUs);
      
      spmd
        validateGPU
      end
      For more information about using remote GPUs, see Work with Remote GPUs.

    Algorithms

    collapse all

    List of Validation Steps

    The validateGPU performs these system-level validation steps.

    Validation StepDescription
    CUDA-supported platform

    CUDA® is supported on the operating system.

    CUDA-enabled graphics driver exists

    A supported CUDA driver is found.

    CUDA-enabled graphics driver load

    MATLAB® can load the CUDA driver.

    CUDA environment variables

    No devices are hidden by environment variables such as CUDA_VISIBLE_DEVICES.

    CUDA device count

    There is at least one device.

    GPU libraries load

    MATLAB can load Parallel Computing Toolbox™ GPU libraries.

    The validateGPU performs these device-level validation steps. If you validate more than one device, then these steps are repeated for each device.

    Validation StepDescription
    Device exists

    MATLAB can detect the device.

    Device supported

    The device's compute capability is supported by MATLAB.

    Device available

    The device is in an available state.

    Device selectable

    MATLAB can select the device.

    Device memory allocation

    MATLAB can create a gpuArray.

    Device kernel launch

    MATLAB can launch a GPU kernel.

    Version History

    Introduced in R2024b