Filter löschen
Filter löschen

How to use GPU to speed up computation?

8 Ansichten (letzte 30 Tage)
MashalS am 19 Feb. 2024
Kommentiert: Jonas am 11 Mär. 2024
% Define the paths to the three video files
videoPaths = {
'F:\LIVE Video Quality Challenge (VQC) Database\LIVE Video Quality Challenge (VQC) Database\Video\A002.mp4',
'F:\LIVE Video Quality Challenge (VQC) Database\LIVE Video Quality Challenge (VQC) Database\Video\A003.mp4',
'F:\LIVE Video Quality Challenge (VQC) Database\LIVE Video Quality Challenge (VQC) Database\Video\A004.mp4'
% Define the folder to save the Excel files
outputFolder = 'F:\FEUsingFriquee_csvFiles\';
% Loop over the selected video files
for videoIdx = 1:numel(videoPaths)
% Open the current video file
videoObj = VideoReader(videoPaths{videoIdx});
numFrames = videoObj.NumFrames;
% Initialize variables to store features
allFriqueeFeats = [];
% Create a parallel pool with 6 workers
if isempty(gcp('nocreate'))
parfor frameIdx = 1:numFrames
% Read frame
frame = read(videoObj, frameIdx);
% Extract features for the current frame
friqueeFeats = extractFRIQUEEFeatures(frame);
% Check if the size of features matches the number of frames processed
if size(friqueeFeats.friqueeALL, 1) ~= 1
continue; % Skip frames with inconsistent feature sizes
% Store features for this frame
allFriqueeFeats = [allFriqueeFeats; friqueeFeats.friqueeALL];
% Organize features for output
videoFeatures.allFriqueeFeats = allFriqueeFeats;
% Define the filename for the current video
[~, videoName, ~] = fileparts(videoPaths{videoIdx});
filename = [videoName, '.xlsx'];
% Full file path for the current video
fullFilePath = fullfile(outputFolder, filename);
% Write the feature matrix to Excel file
writematrix(allFriqueeFeats, fullFilePath);
% Delete the parallel pool
catch ME
fprintf('Error processing video %d: %s\n', videoIdx, ME.message);
continue; % Continue with the next video file
I have to extract features for all frames of each video. the number of frames are 300 and features are 560. The time taken for each video is 8 hours or more and i have to extract feaatures of 500 videos. I have tried to create a pool and use parfor loop to utilize the GPU in order to reduce computation time. However, in task manager, GPU is not being utilized. I have NVIDIA GEFORCE 3050 RTX. How can i use GPU to reduce computation time ?
  6 Kommentare
MashalS am 26 Feb. 2024
Is it necessary to use inbuilt GPU compatible functions to utilize GPU? is there anyother way?
Jonas am 11 Mär. 2024
do i see that correctly that processing 1 frame only, needs 180s, meaning 3min?
starting with this profile, you may have a look into those function with a big dark band. if you need assistance, you may post those function and explain, what they should do, with is input / output etc.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Catalytic am 26 Feb. 2024
Using the GPU in conjunction with parfor will not be productive unless you have a multi-GPU system and assign each parpool worker a different GPU. Otherwise, the workers will just compete for access to the same GPU bus.
  1 Kommentar
MashalS am 26 Feb. 2024
Bearbeitet: MashalS am 26 Feb. 2024
thankyou for answering. I have attached my device specs. If you can guide accordingly. Regards

Melden Sie sich an, um zu kommentieren.


Mehr zu Parallel Computing Fundamentals finden Sie in Help Center und File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by