MATLAB Answers

Matlab compiler resulting ".exe" file size and "cudnn64_*.dll"

28 views (last 30 days)
Igor Varfolomeev
Igor Varfolomeev on 2 Nov 2018
Commented: Daniel on 23 Jan 2020
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".
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?

Accepted Answer

Lipi Vora
Lipi Vora on 20 May 2019
Starting R2019a, the cudnn64_*.dll is not packaged in the CTF by default.
For previous releases, please see bug report:
  1 Comment
Igor Varfolomeev
Igor Varfolomeev on 23 May 2019
I've just tried to build the same code with R2019a update 2 - I can confirm that there's no " cudnn*" inside. The size of the "exe" is 73MB - larger than R2017b_update9 with cudnn renamed (47.9MB).
Now the largest dll inside is "Halide.dll" (55.4MB) (~18MB if packed to zip). Not sure if it's actually used...

Sign in to comment.

More Answers (2)

Daniel on 23 Jan 2020
I noticed that using R2019a, I can replace Halide.dll with a 0-byte dummy file in the executable, to reduce file size. I cannot remove it from the archive since MATLAB checks for the presence of the file, but I can replace it with a dummy file of size zero, and the executable still runs.
I used 7-zip to manipulate the archive/executable.
If compilation isn't done too often, this might be an acceptable solution.
  1 Comment
Daniel on 23 Jan 2020
Forgot to mention: the executable was built with !mcc from the MATLAB command line, using Microsoft Visual C++ 2017, in case the specifics matter.

Sign in to comment.

Sitra on 23 Nov 2018
I'm facing the same thing
I think Mathworks should seriously focus on this BIG TECHNICAL ISSUE. Many programmers when they reach to this point, they will force to re-program their code from scratch using other programming languages (such as Python with pyqt) to avoid large .exe applications as we face with MATLAB
I have designed many great GUIs using MATLAB, but still I cannot compile them to my friends and community because they will start questioning me regarding this unncessary file size! Is it logical to design a simple GUI (like displaying a "Hello World" message only) to end up with a very large file!! If I program the same code using qt with C++ or pyqt with Python, it will be just fee kilobytes files size, automatically without diving into a mysterious codes with mcc -xx; Am I correct?
This is a big boundary and obstacle that should be addressed as one of the highest priority problems that need to be solved immediately
I hope my concern reaches Mathworks to let us benefiting from a great and smart language like MATLAB
Thank you so much
Igor Varfolomeev
Igor Varfolomeev on 26 Nov 2018
I've received the reply from the support. They said they know about the issue (both "CTF size is too large" and about "cudnn64_* is both in CTF and MCR") and that they are working on it.
Well, I hope they would eventually fix this.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!