主要内容

coder.gpuEnvConfig

R2026b

Configuration object for checking GPU code generation environment

Description

The coder.gpuEnvConfig object contains the configuration parameters that coder.checkGpuInstall uses to verify the GPU code generation environment.

Creation

Description

gpuEnvObj = coder.gpuEnvConfig creates a gpuEnvConfig configuration object for the host development computer.

example

gpuEnvObj = coder.gpuEnvConfig(hw) creates a configuration object for the type of hardware specified by hw. For example, to create a configuration for NVIDIA® Jetson™ hardware, enter coder.gpuEnvConfig("jetson").

example

Input Arguments

expand all

Hardware to perform checks on, specified as "host", "jetson", or "drive". To specify the hardware as "jetson" or "drive", you must have the MATLAB® Coder™ Support Package for NVIDIA Jetson and NVIDIA DRIVE® Platforms.

This argument sets the Hardware property.

Properties

expand all

This property is read-only.

Type of hardware to check, represented as 'host', 'jetson', or 'drive'.

ID of the GPU device to check, specified as an integer. Specify the device ID on systems with multiple GPUs.

Example: gpuEnvObj.GpuId = 1;

Option to test code generation, specified as a numeric or logical 1 (true) or 0 (false). When you set this property to true, coder.checkGpuInstall checks GPU code generation for a sample function.

Example: gpuEnvObj.BasicCodegen = true;

Option to test code generation and execution, specified as a numeric or logical 1 (true) or 0 (false). When you set this property to true, coder.checkGpuInstall checks code generation and execution for generated code.

Example: gpuEnvObj.BasicCodeexec = true;

Option to test code generation for a deep learning algorithm, specified as a numeric or logical 1 (true) or 0 (false). When you set this property to true, coder.checkGpuInstall checks GPU code generation for a deep learning algorithm. The code generator uses the library specified by the DeepLibTarget property.

Example: gpuEnvObj.DeepCodegen = true;

Option to test code execution for a deep learning algorithm, specified as a numeric or logical 1 (true) or 0 (false). When you set this property to true, coder.checkGpuInstall checks GPU code generation and code execution for a deep learning algorithm. The code generator uses the library specified by the DeepLibTarget property.

Example: gpuEnvObj.DeepCodeexec = true;

Deep learning library, specified as "none", "cudnn", or "tensorrt". This property indicates the library target for which to perform deep learning code generation and execution checks. To target the NVIDIA cuDNN library, use "cudnn". To target the NVIDIA TensorRT™ library, use "tensorrt".

Set this property to "none" to generate CUDA® code for a deep learning algorithm that does not use third-party libraries.

Example: gpuEnvObj.DeepLibTarget = "cudnn";

NVIDIA TensorRT data precision, specified as an empty string, "fp32", "fp16", or "int8". If you also set the DeepLibTarget property to "tensorrt", coder.checkGpuInstall checks if the compute capability of the selected GPU device meets the minimum compute capability required for the selected TensorRT data precision.

Example: gpuEnvObj.DataType = "fp32";

Option to generate an HTML report with the results of the environment check, specified as a numeric or logical 1 (true) or 0 (false). The coder.checkGpuInstall function generates a report in the current working folder.

Example: gpuEnvObj.GenReport = true;

Option to suppress the command-line output from coder.checkGpuInstall, specified as a numeric or logical 1 (true) or 0 (false).

Example: gpuEnvObj.Quiet = true;

Path to the CUDA libraries on the host, specified as a character vector. The default value depends on the operating system.

  • On Linux®, the default value is the path to the nvcc compiler. If MATLAB cannot find nvcc, the default value is an empty character vector.

  • On Windows®, the default value is the value of the CUDA_PATH environment variable.

Example: gpuEnvObj.CudaPath = "/usr/local/cuda";

Path to the cuDNN libraries on the host, specified as a string scalar or character vector. The default value is the value of the NVIDIA_CUDNN environment variable, if set. If the NVIDIA_CUDNN environment variable is unset, the default value is an empty character vector.

Example: gpuEnvObj.CudnnPath = "/usr/local/cuda/cudnn";

Path to the TensorRT libraries on the host, specified as a character vector. The default value is the value of the NVIDIA_TENSORRT environment variable, if set. If the NVIDIA_TENSORRT environment variable is unset, the default value is an empty character vector.

Example: gpuEnvObj.TensorrtPath = "/usr/local/cuda/tensorrt";

NVIDIA hardware, specified as a jetson or drive object. For NVIDIA Jetson or NVIDIA DRIVE, set this property before running environment checks on the board.

Example: gpuEnvObj.HardwareObject = jetsonHwObj;

Timeout for long-running applications, in seconds, specified as a positive integer.

Example: gpuEnvObj.ExecTimeout = 25;

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

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 R2019a

expand all