Matlab验证CUDA和cuDNN报错解决

一、配置Matlab的深度学习环境时,需验证GPU环境是否安装CUDA和cuDNN。

运行如下代码进行验证时却报错了

%% 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);

报错为:

错误使用 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.)

翻译为:

一个或多个系统检查没有通过,出现以下错误…
cuDNN环境:(无法找到’NVIDIA_CUDNN’环境变量。设置指向NVIDIA cuDNN安装根目录的’NVIDIA_CUDNN’。)

二、问题解决

1.设置环境变量NVIDIA_CUDNN

1.在Matlab中设置环境变量,加入代码

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

此时代码如下:

%% 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.点击Add-On Explorer安装GPU Coder Interface

运行后又报错:

错误使用 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.)

翻译为:

一个或多个系统检查没有通过,出现以下错误…
深度学习(cuDNN)代码生成:cuDNN目标库的深度学习代码生成需要GPU Coder Interface for Deep Learning Libraries 支持包。要安装此支持包,请使用附加组件浏览器。)

点击Add-On Explorer,按指引安装即可
再次运行,即可通过。

猜你喜欢

转载自blog.csdn.net/qq_36674060/article/details/123177726