MATLAB: Matlab compiler resulting “.exe” file size and “cudnn64_*.dll”

cudnnImage Processing ToolboxMATLABmatlab compiled standalone app large sizeMATLAB Compilermatlab compiler runtimemccParallel Computing Toolbox

I'm recently used Matlab Compiler mcc command to create a standalone executable (there's no MCR installed included). And found that the resulting " .exe" size is somewhat too large — 289 MB. I do not feel myself comfortable, when I need to pass an exe like this to my colleague – he might say something bad about Matlab 🙂 .
I known the ` -N` switch, that allows to prevent including not-actually-needed toolboxes. It doesn't help. The toolboxes I do need here are: Parallel Processing and Image Processing.
The ".exe" files were not that big before, so I've decided to try several Matlab versions, and unpack each " .exe" generated. I've immediately noticed that the largest file inside is " cudnn64_*.dll".
Results:
release exe size cudnn size cudnn_name
------- -------- ---------- ---------------
R2018b 289 MB 324 MB "cudnn64_7.dll"
R2017b_Update9 230 MB 284 MB "cudnn64_7.dll"
R2017b_noUpdates 81 MB 75 MB "cudnn64_5.dll"
R2016b 32.2MB 0 MB *no such file*
So, " cudnn*.dll" plays a major role in wasting space here.
I do not use this ".dll" in this project, actually. I wonder why Matlab thinks I do. So, I've temporarily renamed it to ".dll__", and re-compiled my ".exe". And now the resulting ".exe" got significantly smaller (29MB in R2017b_noUpdates, which looks more-or-less OK). And it still works. Maybe this approach would help someone else.
My questions are:
  • So.. Any idea how to improve this even further, without too much effort?
  • There is a copy of this dll in the MCR installation itself (the same, byte-to-byte, except for "R2017b_Update9" — there's just no MCR updates available currently) . Why include it both here and there? Why R2016b is "smarter", and does not not include this unnecessary dll? Is this regression a bug?

Best Answer

Starting R2019a, the cudnn64_*.dll is not packaged in the CTF by default.
For previous releases, please see bug report: