MATLAB Coder: How do I build the Intel MKL-DNN library for Deep Learning C++ code generation and deployment?
Mostrar comentarios más antiguos
I see a few deep learning networks supported for code generation using MATLAB Coder:
I'm looking to generate code from my deep learning network (like AlexNet, GoogLeNet, ResNet, SqueezeNet, VGG-16/19, etc) to run on Intel CPUs using MATLAB Coder and the Intel MKL-DNN library. What are the steps to do this?
Respuesta aceptada
Más respuestas (2)
21 comentarios
Mark Brinton
el 9 de Mayo de 2019
Very helpful. Thanks!
Usatyuk Vasiliy
el 30 de Ag. de 2019
Bill Chou, Thank you!
Praveen Kumar Gajula
el 24 de En. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
Hi Xiaoqi,
As per the R2019b pre-requisites documentation we use the mkldnn v0.14 . The above build steps will suffice for the mkldnn v0.14.
We will update the steps as you mentioned once we support latest mkldnn version.
Thank you,
Praveen.
Sviatoslav Klos
el 4 de Feb. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
I have such an error: Undefined function or variable 'IsAvx512Proc'.
I thought that if my Intel proc does not support Avx512 then it would just use Avx2. Does it make sense? Had someone try MKL-DNN with Intel i5-8265u?
Praveen Kumar Gajula
el 7 de Feb. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
Hi Sviatoslav,
We are sorry to hear that you are facing issues.
You are right that if Intel proc doesnot support Avx512 mkldnn should use Avx2.
And processor i5-8265u should be able to use mkldnn with out any issues.
There is a package installer issue from our end , where it didnot ship the 'IsAvx512Proc' method. Hence you are seeing this error . Could you let me know what is the MATLAB version you are using and did you do any recent upgrade to it.
Thank you,
Praveen.
Sviatoslav Klos
el 7 de Feb. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
Thank you for yout response.
Such issues were observed while using R2019a. I tried 2019b and it works there.
P.S. It would be nice if it would be possible to generate ScalingLayer using codegen. In addition, it would be nice if it would be possible to export TanhLayer and ScalingLayer to ONNX format.
Jaya Shankar
el 11 de Feb. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
Hi Sviatoslav,
Deep learning toolbox has a few scaling layer implementations. For instance , there is one implemented for inceptionV3 networks and there is a scaling layer for reinforcement learning toolbox. Can you clarify which one you are using ?
Note that codegen is supported for the scaling layer in inceptionV3 networks since 19a.
Thanks
Jaya
sara alamri
el 14 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
didn't work for me !
need help quick please

Praveen Kumar Gajula
el 14 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
Hi ,
Error is not clear from this image. Could you share us Error report.
Could you also share the MATLAB release details and example link that you are trying out.
Thank you,
Praveen.
sara alamri
el 15 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
here is the report of the error in the attachment
i use Matlab R2019b
i also tried to this instructions to install mkl dnn
and your instruction but didn't work
i also tried all example in matlab website that related to YOLO code genrator.. all same error
all i want from this is to convert my code"which contain a yolo detector" to C so i can combine it with an android app.
Praveen Kumar Gajula
el 16 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
The compilation errors are becuase of mkldnn.hpp file not found.
" c:\users\witch\documents\matlab\examples\r2019b\deeplearning_shared\yolov2objectdetectionusingintelmkldnnexample\codegen\mex\yolov2_detection\MWCNNLayerImpl.hpp(10): fatal error C1083: Cannot open include file: 'mkldnn.hpp': No such file or directory
"
Could you check if you setup the INTEL_MKLDNN path correctly as mentioned in step -
setenv('INTEL_MKLDNN', 'C:\Program Files\mkl-dnn\')
Also could you make sure that there are no spaces in the folders
- Where you are trying codegen.
- Where MKLDNN libraries reside.
Thank you,
Praveen.
sara alamri
el 16 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
the file is already exist
and there is no space in both paths
I FIX this bug by move this file into project folder
but another error happend : fatal error LNK1181: cannot open input file 'lib\mkldnn.lib'
ninja: build stopped: subcommand failed.
my CPU is intel core i7 7th Gen 2.7 GHz
sara alamri
el 16 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
now this error
compilation aborted for MWElementwiseAffineLayer.cpp (code 4)
.....
catastrophic error: cannot open source file "mkldnn.hpp"
...
compilation aborted for MWExponentialLayer.cpp (code 4)
ninja: build stopped: subcommand failed.
Praveen Kumar Gajula
el 16 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
We tried the same example and found the same log as yours if we donot set the INTEL_MKLDNN path.
Currently you are seeing the log similar to log present in withOutMKLDNNPath.txt where the INTEL_MKLDNN is not set in the MATLAB. If you set it appropriately you should see log similar to withMKLDNNPATH
Thank you,
Praveen.
sara alamri
el 17 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
now i had this error in the attachment using matlab R2019b
and this error using matlab R2019a
??? Error generating code for network yoloV2CatDetector_0. Code generation for
YOLOv2TransformLayer yolov2Transform is not supported for mkldnn target. See documentation
for a list of supported layers with each target.
i use mkldnn V0.14
i also installed minGW v17 which i belive it supports openMP
Praveen Kumar Gajula
el 18 de Mzo. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
We donot support the yolov2 for R2019a release.
Regarding the errors in R2019b ,we are unable to reproduce .
It would be great if you could forward the steps that you have used for codegen. This will help us to corner out if there are any steps that are missed out.
Than kyou,
Praveen.
Tohru Kikawada
el 3 de Mayo de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
I think you need to set up the C++ compiler before you build. Please try mex -setup c++. The following link explains for more details.
Mahmoud Abdulsalam
el 9 de Jun. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
I have generated a source code for deep learning and found a lot of files in codegen folder. How do I go about integrating it and compile it in Linux.Do I need to make changes to the main.cpp? Because I saw some instructions within the main file asking me to change variable size function argument.
Hanumanth Hanumantharayappa
el 9 de Jun. de 2020
Movida: Bill Chou
el 14 de Feb. de 2023
Hi Mahmoud,
Can you take a look at this below documentation? Let me know if this helps.
Hanumanth
9 comentarios
JJ L
el 11 de Oct. de 2020
Hello, Bill Chou,
I am using the matlab 2020b, and I just installed the Visual Studio 2019 and Intel Parallel Studio XE.
With in the folder of oneDNN-1.0, when I run the commands, the "cmake" cannot be found, so I cannot start your process at all. What should I do?
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" ..

Thank you very much!
Jaya Shankar
el 12 de Oct. de 2020
Hi JJ,
cmake needs to be run as a system command. Please run the cmake commands from your Windows terminal instead of running them within MATLAB.
Jaya
JJ L
el 13 de Oct. de 2020
Thank you, I will try
Oleg Kyrmyzy
el 2 de Nov. de 2020
Is there a mistake? In C++ Compiler requirements you specified "Microsoft Visual C++ 14.0 (Visual Studio 2015 Update 3)", but in step two you wrote "cmake -G "Visual Studio 15 2017 Win64" ..".
Should be "cmake -G "Visual Studio 14 2015 Win64" .."
Praveen Kumar Gajula
el 2 de Nov. de 2020
Bonan Yu
el 17 de Nov. de 2020
I have a question about the installation guide MATLAB 2020a in windows:
all built library files in fold oneDNN-1.0. should be copied to C:\Program Files\mkl-dnn
So what I supposed to do is to create mkl-dnn/lib and mkl-dnn/include files then copy the files built in oneDNN-1.0 seperately to mkl-dnn/lib and mkl-dnn/include? However it doesn't work (errors below, it seems like mkl-dnn wasn't correctly installed), maybe because I used MATLAB 2020b? I'm installing 2020a...
Making simulation target "deployment_C_2_sfun", ...
error: 'agentData1' does not name a type
agentData1.mat_policy_9_1_1_1_1_1_1_1_ anchor;
^~~~~~~~~~
gmake: *** [deployment_C_2_sfun.obj] Error -1
Component:Make | Category:Make error
Unable to create mex function 'deployment_C_2_sfun.mexw64' required for simulation.
Component:Simulink | Category:Model error
I also checked my mkl-dnn files installed in anaconda3, there are also bin flies and LICENCE! So is there something wrong in my installation???





--------------------------------------------------------------------------------------------------------------------------------------------------
mkl-dnn in Anaconda3

Thanks in advance !!!
Praveen Kumar Gajula
el 18 de Nov. de 2020
Hi Bonan,
In 20a and 20b we use the same oneDNN1.0 version. There might be conflict of presence of 2 mkldnn libraries installed . Are these 2 paths set as part of environement vairiable. If so, then try to remove anaconda related path from environemnt vairiables and try out. That should solve your problem.
Thanks,
Praveen.
Junyu Quan
el 11 de Ag. de 2021
Hi Praveen
I have the same problem with Bonan. For"all built library files in fold oneDNN-1.0. should be copied to C:\Program Files\mkl-dnn" I find that I don't have the folder named mkl-dnn, dose it means I have error in installation? Or I should create the folder by my self?
Praveen Kumar Gajula
el 16 de Ag. de 2021
Hi Junyu,
You need to create folders "mkl-dnn", "lib" and copy the libraries to C:\Program Files\mkl-dnn\lib.
Thanks,
Praveen
Categorías
Más información sobre Deep Learning Code Generation Fundamentals en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



