use gpu for image processing
Mostra commenti meno recenti
hello, I have created about 1500 images on disk. I process them, store the results as mat files on disk, say image1_result1.mat, then read these results from another function which also creates a mat file after its processing say image1_result2.mat.
so i do these iteratively for all the 1500 images. But i noticed that my pc, despite having gpu, is using the cpu. In fact GPU used by matlab is 0% while cpu oscillates between 24% and about 94%.
Now am wondering if there's a way to execute these operations using the gpu in matlab. if so how best can I modify the code.
Structure of the main script that is looping is like this:
for i=1:total_images % do this for all images
[p, n, e] = fileparts(image_name);
image = image_name; % 'Image1.jpg';
param_one = p1;
param_two = p2;
% generate params for algorithm 1 from the image
generateParams(image, param_one); % saves results in image1_result.mat
% create corresponding database for the image
create_data(image, param_two); % reads param_two and others from image1_result.mat
% get the re-created image using algorithm
create_final(image_name, param_one); % stores results in image1_final.mat
end
for i=1:total_images
load('imagei_final'); % loads final results of image i from disk for calculations
use these results to calculate statistics.
end
How best can i convert this to a gpu executable algorithm to have faster performance, if possible? thanks.
3 Commenti
Joss Knight
il 12 Giu 2021
You'd have to show us the contents of your processing functions for us to know why the GPU is not used.
I get the impression that you were expecting your GPU to be used without any changes to your code. There are only a few things in MATLAB that behave like that. You should probably make sure you've read MATLAB's documentation on GPU support.
MatlabEnthusiast
il 13 Giu 2021
Joss Knight
il 14 Giu 2021
Sorry, it's not possible to know without seeing your code. Every function that has gpuArray input will have gpuArray outputs, so typically you only need to convert your initial input data; unless you are loading or generating new data inside your function. And then if you are using certain functions in Deep Learning and some other toolboxes you may find that no changes are needed to leverage the GPU. So we can't say for sure.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!