coder.gpuEnvConfig
R2026bConfiguration 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.
Input Arguments
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
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
nvcccompiler. If MATLAB cannot findnvcc, the default value is an empty character vector.On Windows®, the default value is the value of the
CUDA_PATHenvironment 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";
Timeout for long-running applications, in seconds, specified as a positive integer.
Example: gpuEnvObj.ExecTimeout = 25;
Examples
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: 0To 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: 1Create 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: 0Alternative 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 R2019aThe default value of the DeepLibTarget property is now
none, which specifies that the configuration object does not use
third-party deep learning libraries. In previous releases, the default value of
DeepLibTarget was an empty character array, and you set it to
"none", "cudnn", or "tensorrt"
before deep learning code generation.
The Profiling and NvtxPath properties have
been removed. Setting these properties generates an error.
In previous releases, you set the NvtxPath and
Profiling properties to check the installation of the NVTX libraries
requires for profiling. The NVTX libraries are no longer
required for profiling, and you do not need to check profiling. Delete code that sets the
Profiling or NvtxPath properties of a
coder.gpuEnvConfig object.
Setting the Profiling property of a
coder.gpuEnvConfig object to true generates a warning
and does not check profiling.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)