Matlab使用coder.checkGpuInstall时报错‘emlc:compilationError‘

一、问题描述

环境:
CUDA11.5
cuDNN8.3 for CUDA 11.5
MATLABR2021b
MATLAB已安装 “GPU Coder Interface for Deep Learning Libraries support package”, “MATLAB Support for MinGW-w64 C/C++ Compiler”
未安装Microsoft Visual Studio
运行如下代码检查环境:

envCfg = coder.gpuEnvConfig('host');
envCfg.DeepLibTarget = 'cudnn';
envCfg.DeepCodegen = 1;
envCfg.Quiet = 1;
coder.checkGpuInstall(envCfg);

显示错误:

Error using coder.checkGpuInstall (line 32)
One or more of the system checks did not pass, with the following errors ...
Basic Code Generation: (Test GPU code generation failed with the error 'emlc:compilationError'. View report for further information: View report)

点击View report,显示 :

Build error: C++ compiler produced errors. See the Build Log for further details.

因此继续用*coder.checkGpuInstall();*详细检查各环境,显示:

Compatible GPU           : PASSED 
CUDA Environment         : PASSED 
	Runtime   : PASSED 
	cuFFT     : PASSED 
	cuSOLVER  : PASSED 
	cuBLAS    : PASSED 
cuDNN Environment        : PASSED 
Basic Code Generation    : FAILED (Test GPU code generation failed with the error 'emlc:compilationError'. View report for further information: View report)

二、问题解决

回想起之前安装CUDA时,按照教程取消勾选Visual Studio Integration,防止与已安装的Visual Studio冲突。但是那时我并没有安装Visual Studio,因此推测是由于未安装Visual Studio导致的。
因此,首先安装Visual Studio 2019后重启(Visual Studio 2015及以上版本,包含C++),再次运行coder.checkGpuInstall,显示:

Compatible GPU           : PASSED 
CUDA Environment         : PASSED 
	Runtime   : PASSED 
	cuFFT     : PASSED 
	cuSOLVER  : PASSED 
	cuBLAS    : PASSED 
cuDNN Environment        : PASSED 
Basic Code Generation    : PASSED 
Basic Code Execution     : PASSED 

再次运行开头的代码段:

envCfg = coder.gpuEnvConfig('host');
envCfg.DeepLibTarget = 'cudnn';
envCfg.DeepCodegen = 1;
envCfg.Quiet = 1;
coder.checkGpuInstall(envCfg);

正常运行未报错。
问题解决。

解决方法参照此连接

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值