Contenuto principale

coder.checkGpuInstall

R2026b

Verify GPU code generation environment

Description

results = coder.checkGpuInstall(cfg) checks whether your environment has tools and libraries for GPU code generation. The configuration cfg is a coder.gpuEnvConfig object. The coder.checkGpuInstall function performs the checks that you enable in the cfg object.

By default, the checks run on the host computer with MATLAB®. You can also configure the checks to run on NVIDIA® Jetson™ or NVIDIA DRIVE® devices.

Before using this function, install and set up the required prerequisite third-party compilers, libraries, and tools. For more information, see Installing Prerequisite Products and Setting Up the Prerequisite Products.

example

Examples

collapse all

To check if you can generate and execute GPU code, first create a coder.gpuEnvConfig object.

cfg = coder.gpuEnvConfig;

To enable GPU code generation and execution checks, set the BasicCodegen and BasicCodeexec properties to true.

cfg.BasicCodegen = true;
cfg.BasicCodeexec = true;

Check code generation and execution.

result = coder.checkGpuInstall(cfg)
Compatible GPU           : PASSED 
CUDA Environment         : PASSED 
	Runtime   : PASSED 
	cuFFT     : PASSED 
	cuSOLVER  : PASSED 
	cuBLAS    : PASSED 
Host Compiler            : PASSED 
Basic Code Generation    : PASSED 
Basic Code Execution     : PASSED 

result = 

  struct with fields:

                 gpu: 1
                cuda: 1
               cudnn: 0
            tensorrt: 0
        hostcompiler: 1
        basiccodegen: 1
       basiccodeexec: 1
         deepcodegen: 0
    tensorrtdatatype: 0
        deepcodeexec: 0

To check if you can generate code for and execute a deep learning algorithm, create a coder.gpuEnvConfig object, and set the DeepCodegen and DeepCodeexec properties to true.

cfg = coder.gpuEnvConfig;
cfg.DeepCodegen = true;
cfg.DeepCodeexec = true;

To check code generation and execution that uses a third-party deep learning library, such as NVIDIA TensorRT™, set the DeepLibTarget property. In this example, set the property to "none".

cfg.DeepLibTarget = "none";

Check if your environment can generate and execute deep learning code.

result = coder.checkGpuInstall(cfg)
Compatible GPU           : PASSED 
CUDA Environment         : PASSED 
	Runtime   : PASSED 
	cuFFT     : PASSED 
	cuSOLVER  : PASSED 
	cuBLAS    : PASSED 
Host Compiler            : PASSED 
Deep Learning (CUDA) Code Generation: PASSED 
Deep Learning (CUDA) Code Execution: PASSED 

result = 

  struct with fields:

                 gpu: 1
                cuda: 1
               cudnn: 0
            tensorrt: 0
        hostcompiler: 1
        basiccodegen: 0
       basiccodeexec: 0
         deepcodegen: 1
    tensorrtdatatype: 0
        deepcodeexec: 1

Create a coder.gpuEnvConfig object with the "jetson" hardware type.

cfg = coder.gpuEnvConfig("jetson");

To specify which Jetson board you want to check, specify the HardwareObject property of the coder.gpuEnvConfig object. For example, if hwObj is a jetson object, use this code.

cfg.HardwareObject = hwObj;

Enable GPU code generation and execution checks. Check the environment on the hardware board.

cfg.BasicCodegen = true;
cfg.BasicCodeexec = true;
result = coder.checkGpuInstall(cfg);
Compatible GPU           : PASSED 
CUDA Environment         : PASSED 
	Runtime   : PASSED 
	cuFFT     : PASSED 
	cuSOLVER  : PASSED 
	cuBLAS    : PASSED 
Basic Code Generation    : PASSED 
Basic Code Execution     : PASSED 

result = 

  struct with fields:

                 gpu: 1
                cuda: 1
               cudnn: 0
            tensorrt: 0
        basiccodegen: 1
       basiccodeexec: 1
         deepcodegen: 0
    tensorrtdatatype: 0
        deepcodeexec: 0

Input Arguments

collapse all

GPU code generation environment configuration, specified as a coder.gpuEnvConfig object.

Output Arguments

collapse all

GPU environment checking results, returned as a structure of logical values that indicate whether a check passed. This table shows what a true value for each field of the results structure represents:

FieldDescription
gpuThere is a supported GPU connected to MATLAB.
cudaThe specified hardware has a supported CUDA® Toolkit installation.
cudnnThe specified hardware has a supported cuDNN installation on the development host or, if you specified a hardware object, on the hardware.
tensorrtThe specified hardware has a supported TensorRT installation.
hostcompilerThe development host has a supported compiler.
basiccodegenThe selected hardware can generate CUDA code.
basiccodeexecThe specified hardware can generate and execute CUDA code.
deepcodegenThe specified hardware can generate CUDA code for deep learning.
tensorrtdatatypeThe specified hardware has at least the minimum compute capability for the selected TensorRT data type.
deepcodeexecThe specified hardware can generate and execute CUDA code for deep learning.

Alternative Functionality

App

Use the GPU Environment Check app to verify that your environment has third-party libraries and tools for GPU code generation.

Version History

Introduced in R2017b