Matlab verifies CUDA and cuDNN error resolution

1. When configuring the deep learning environment of Matlab, it is necessary to verify whether CUDA and cuDNN are installed in the GPU environment.

When running the following code for verification, an error is reported

%% Verify GPU Environment
%
% Use the <docid:gpucoder_ref#mw_0957d820-192f-400a-8045-0bb746a75278 coder.checkGpuInstall> function
% to verify that the compilers and libraries necessary for running this example
% are set up correctly.
envCfg = coder.gpuEnvConfig('host');
envCfg.DeepLibTarget = 'cudnn';
envCfg.DeepCodegen = 1;
envCfg.Quiet = 1;
coder.checkGpuInstall(envCfg);

The error is reported as:

错误使用 coder.checkGpuInstall (第 33 行)
One or more of the system checks did not pass, with the following errors …
cuDNN Environment: (Unable to find the ‘NVIDIA_CUDNN’ environment variable. Set ‘NVIDIA_CUDNN’ to point to the root directory of a NVIDIA cuDNN installation.)

translates to:

One or more system checks failed with the following error...
cuDNN environment: (Unable to find 'NVIDIA_CUDNN' environment variable. Set 'NVIDIA_CUDNN' to point to the root of your NVIDIA cuDNN installation.)

2. Problem solving

1. Set the environment variable NVIDIA_CUDNN

1. Set environment variables in Matlab and add code

setenv('NVIDIA_CUDNN','C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6')

At this point the code is as follows:

%% Verify GPU Environment
%
% Use the <docid:gpucoder_ref#mw_0957d820-192f-400a-8045-0bb746a75278 coder.checkGpuInstall> function
% to verify that the compilers and libraries necessary for running this example
% are set up correctly.
envCfg = coder.gpuEnvConfig('host');
envCfg.DeepLibTarget = 'cudnn';
envCfg.DeepCodegen = 1;
envCfg.Quiet = 1;
% % 指定 CUDA 安装目录,您必须已经在那里复制了 cudnn 文件
% setenv('NVIDIA_CUDNN','C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6')
coder.checkGpuInstall(envCfg);

2. Click Add-On Explorer to install GPU Coder Interface

After running, an error is reported:

错误使用 coder.checkGpuInstall (第 33 行)
One or more of the system checks did not pass, with the following errors …
Deep Learning (cuDNN) Code Generation: (Deep Learning code generation for target library cuDNN requires GPU Coder Interface for Deep Learning Libraries support package. To install this support package, use the Add-On Explorer.)

translates to:

One or more system checks failed with the following error...
Deep Learning (cuDNN) Code Generation: Deep Learning code generation for the cuDNN target library requires the GPU Coder Interface for Deep Learning Libraries support package. To install this support pack, use the Add-ons Browser. )

Click Add-On Explorer, follow the instructions to install and then
run it again to pass.

Guess you like

Origin blog.csdn.net/qq_36674060/article/details/123177726