GPU code generation failed with the error 'emlc:compilationError'
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Shi
am 21 Mär. 2025
Kommentiert: Alessandro
am 12 Sep. 2025
When using GPU Coder, I encountered issues with the following environment configuration:
- **GPU Version**: NVIDIA RTX A2000 (Compute Capability 8.6, Ampere Architecture).
- **MATLAB Version**: R2023b.
- **CUDA Toolkit Version**: 11.8.
- **Visual Studio Version**: 2022 (with "Desktop Development with C++" component installed).
When I test
gpuDevice
ans =
CUDADevice - 属性:
Name: 'NVIDIA RTX A2000'
Index: 1
ComputeCapability: '8.6'
SupportsDouble: 1
GraphicsDriverVersion: '572.83'
DriverModel: 'WDDM'
ToolkitVersion: 11.8000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152 (49.15 KB)
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 6435504128 (6.44 GB)
AvailableMemory: 5375778816 (5.38 GB)
CachePolicy: 'balanced'
MultiprocessorCount: 26
ClockRateKHz: 1200000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceAvailable: 1
DeviceSelected: 1
If I test coder.checkGpuInstall
coder.checkGpuInstall:
Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN Environment : FAILED (Error generated while determining cuDNN library version 'Embedding metadata in the MEX file failed.
'.)
Host Compiler : PASSED
Basic Code Generation : FAILED (GPU code generation failed with the error 'emlc:compilationError'. View report for further information: View report)
ans =
包含以下字段的 struct:
gpu: 1
cuda: 1
cudnn: 0
tensorrt: 0
hostcompiler: 1
basiccodegen: 0
basiccodeexec: 0
deepcodegen: 0
deepcodeexec: 0
tensorrtdatatype: 0
profiling: 0
test mex -setup
mex -setup
MEX 配置为使用 'MinGW64 Compiler (C)' 以进行 C 语言编译。
要选择不同的 C 编译器,请从以下选项中选择一种命令:
MinGW64 Compiler (C) mex -setup:C:\Users\石海洋\AppData\Roaming\MathWorks\MATLAB\R2023b\mex_C_win64.xml C
Microsoft Visual C++ 2022 (C) mex -setup:'D:\Program Files\MathWorksR2023B\bin\win64\mexopts\msvc2022.xml' C
要选择不同的语言,请从以下选项中选择一种命令:
mex -setup C++
mex -setup FORTRAN
I looked throught the answers about 'emlc:compilationError' and "Invalid CUDA device", and see the answer in GPU coder :basic Code Generation failed - MATLAB Answers - MATLAB Central, its issue is caused by a MATLAB version that is too low. However, after reviewing the relevant settings, my MATLAB version should support CUDA 11.8 and VS2022. So, what could be the problem?
PS: I installed cuDNN 8.9 (cudnn-windows-x86_64-8.9.7.29_cuda11-archive) and set the system environment variable `NVIDIA_CUDNN` to: `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8`. Why does the cuDNN Environment still show as failed here?
1 Kommentar
Joss Knight
am 22 Mär. 2025
It might be worth noting that cuDNN is installed separately from the CUDA toolkit and isn't installed in the same location, so it doesn't make sense to make NVIDIA_CUDNN point to the toolkit location.
Akzeptierte Antwort
Chao Luo
am 21 Mär. 2025
Verschoben: Walter Roberson
am 21 Mär. 2025
Hi Shi,
Can you make sure you are using Visual Studio as the MEX C++ compiler by running "mex -setup C++"? GPU Coder only support Visual Studio, not MinGW.
Since you are using Visual Studio 2022, it is very likely the version of Visual Studio 2022 is not supported by CUDA 11.8. CUDA 11.8 only support Visual Studio with __MSC_VER from 1910 to 1939.
To find out __MSC_VER, you can open "Developer Command Prompt for VS 2022", and type "cl.exe", it should print message like this:
C:\Program Files\Microsoft Visual Studio\2022\Professional>cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
19.39 is the __MSC_VER of this Visual Studio.
Latest Visual Studio 2022 is newer than 19.40, and it is not supported. You can try Visual Studio 2019 if it is possible.
3 Kommentare
Alessandro
am 12 Sep. 2025
@chao luo: I have a similar issue. Would it be possible to share the download link for VS 2019? Unfortunately the microsoft website is confusing and I wasn't able to locate it
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with GPU Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!