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,按指引安装即可
再次运行,即可通过。

  • 8
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值