How to evaluate the GPU/CPU trainiing and inference time for a deep learning model in Matlab ?
21 次查看(过去 30 天)
显示 更早的评论
Currently, I need to build a deep learning digit recognition model in Matlab R2023a and fill out this table.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1580021/image.png)
What would be the most efficient way to do this in Matlab ?
My GPU is RTX 3080 so I gues I could do it easily.
回答(1 个)
Debraj Maji
2024-1-4
I understand that you are trying to evaluate the time required for training and inference for a Deep Learning Model. To evaluate the GPU/CPU training and inference time for a deep learning model in MATLAB, you can use the “tic” and “toc” functions. Additionally, MATLAB provides the “gputimeit” function to accurately measure the time taken by GPU operations.
Training time can be found out using the training progress window which pops up after training starts on the top right hand corner of the page.
Here is the sample code for using “tic” and “toc” functions for inference:
tic;
predictions = classify(trainedNet, testData);
elapsedTime = toc;
For further information on the “tic” and “toc” functions you can refer to the following documentation:
Attached below is the sample code for the “gputimeit” function which is used to accurately measure time taken for processes on a GPU:
inferenceFcn = @() classify(trainedNet, testData);
if canUseGPU()
gpuTime = gputimeit(inferenceFcn);
fprintf('Inference time on GPU: %f seconds\n', gpuTime);
end
The Parallel Processing Toolbox is required to run the function “gputimeit” and it will give error otherwise.
For further information on “gputimeit” function you can refer to the following documentation:
Hope this helps,
Regards,
Debraj.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!