MATLAB Answers

How to get the calculation amount of deep network FLOPS? Analyze Network app does not seem to count this metric?

22 views (last 30 days)
cui
cui on 9 Aug 2019
Commented: cui on 24 Sep 2021 at 7:13
In the matlab analyzeNetwork app, the general CNN model can have the required number of parameters, the size of the feature map, but no flops?...

Accepted Answer

Walter Roberson
Walter Roberson on 24 Sep 2021 at 4:59
This is quite unlikely to happen in the near future, if ever.
The translation of cuda calls into machine instructions depends on the level of optimization, and the ability of the compiler, and the cuda version. The translation of machine instructions into gflops depends on the other instructions scheduled and on the exact model — because even within one architecture, they put out models with different numbers of controllers (SMs) and very different implementations of double precision. The models with the highest double precision performance are never the models with the highest single precision, and it is not uncommon for the model from the previous architecture that had the highest double precision, to have higher double precision than most of the models with the new architecture.
  3 Comments

Sign in to comment.

More Answers (2)


cui
cui on 7 Jul 2021
Edited: cui on 30 Jul 2021
gpuDevice
Error using gpuDevice (line 26)
Failed to load graphics driver. Unable to load library 'libcuda.so.1'. The error was:
libcuda.so.1: cannot open shared object file: No such file or directory
Update or reinstall your graphics driver. For more information on GPU support, see GPU Support by Release.
%% MATLAB R2021a
net50 = resnet50;
h=224;
w = 224;
layer = 'fc1000';
%% evaluate
X = gpuArray(rand(h,w,3));
features = activations(net50,X,layer);
dev = gpuDevice(1);
for i = 1:100
scalar = i;
X = gpuArray(rand(h*scalar,w*scalar,3));
% X = dlarray(X);
try % Out of memory on device.
t1 = tic;
features = activations(net50,X,layer,...
'Acceleration','none',...
'ExecutionEnvironment','gpu');
[H,W,C] = size(X);
ElapseTime(i) = toc(t1);
avaiableMem(i) = dev.AvailableMemory/(1024^2);
sizeInput(i) = H;
fprintf('input size:(%i*%i),耗时:%.2f秒,可用显存大小为:%g Mb\n',...
H,W,ElapseTime(i),avaiableMem(i));
catch
break
end
end
%% plot
figure('Color','white');
yyaxis left;
plot(sizeInput,ElapseTime,'-o','LineWidth',2);
xlabel('input image size')
ylabel('ElapseTime(s)')
yyaxis right;
plot(sizeInput,avaiableMem,'-o','LineWidth',2);
ylabel('Avaiable Memory(MB)')
grid on;
title('Indirect Evaluation of DeepNetwork computational power and number of parameters ')
FLOPs and #params correspond to ElapseTime, Avaiable Memory respectively.
The answer can be seen indirectly in this diagram.
run in MATLAB 2021a, win10

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!