My code is slower on a more powerful machine?

21 views (last 30 days)
Hey guys, I ran my code on my Windows 10 machine that has 8 cores of CPU and 16 GB of RAM on MATLAB 2022b. And then ran the same code on a Linux Ubuntu machine that has 128 cores of CPU and 512 GB of RAM on MATLAB 2020b. The code was significantly slower on the Linux machine even though the machine is MUCH more powerful. Is it due to a difference in the OS or a difference in the MATLAB version? Or is it something else? I am not sure. Here is my code (its basically a code to train a neural network to fit a variable in terms of other 7 variables):
Table=AM03_a02b; %a table of 2000 rows and 18 columns of decimal values
Matrix=Table{:,:};
Input=Matrix(1:end,[1:3,7:10]); %the inputs to the neural network that will be used in the training
Output=Matrix(1:end,13); %the output of the neural network that will be used in the training
% Resizing The Matricies
Input=Input';
Output=Output';
ANN=newff(Input,Output,[100 100 100]); %a neural network with three layers and 100 neurals per layer
ANN.trainFcn = 'trainrp';
ANN.trainParam.max_fail=10;
ANN.trainParam.epochs=1000; %a total of 1000 iterations
% Training Process
ANN=train(ANN,Input,Output);
view(ANN)

Accepted Answer

Ashutosh
Ashutosh on 23 Aug 2023
The following could be the possible reasons for such performance in Linux as compared to Windows:
  • As Windows machine is using MATLAB R2022b it would have better performance optimizations as compared to R2020b. Try to update MATLAB version to latest release in Linux machine.
  • MATLAB has support for parallel computing, but the code is not able to utilize it effectively resulting in inefficient performance. Try to explore Parallel Computing Toolbox to improve performance.
  • Try to profile the MATLAB code using built in profiler ("profile" function) to identify the performance bottlenecks by tracking the execution time and work on improving it.
Following links are helpful in improving performance:

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!