Why is Matlab deep learning so much slower than Tensorflow in Python
81 views (last 30 days)
Show older comments
Dear all,
I have created an identical neural net in Matlab and in Tensorflow.
I want to use the Matlab implementation as it is needed in a bigger project.
However, the Matlab implementation is 20x slower to converge than the Tensorflow implementation while also having a higher loss.
Can anyone explain me why this could happen?
I am using a fully connected network with 5 layers and relu activations and use Adam to train the network. The parameters and the network are identical for the implementations.
Thank you in advance!
Best, Steven
3 Comments
Answers (1)
atharva
on 13 Nov 2023
Hey Steven,
I understand that you are facing an issue where the Matlab implementation is 20x slower to converge than the Tensorflow implementation.
You can try the GPU Coder which has been tested to run about 2X as fast as Tensorflow on average. If you do not have the toolbox, you can test out a trial version to see how the performance compares. There are instances where GPU Coder code runs multiple times faster than MATLAB code. An example of this is shown in the video from the following documentation page:
For an introduction to using the GPU Coder for deep learning, please see the following documentation pages:
Please note that there are some prerequisites for installing GPU Coder. For a complete list, please see the documentation page below:
Please note that many factors affect the run time, including the GPU, the original MATLAB code, and the optimization settings selected in GPU Coder, so we cannot guarantee a speed up from using GPU Coder instead of the Deep Learning Toolbox.
I hope this helps!
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!