What is the best way to determine if a usable GPU is available?

10 Ansichten (letzte 30 Tage)
I have an app that is used by many people in our collaboration some with GPU's and parallel toolbox and some without.
I can't seem to the find the canUseGPU() function that returns true if the parallel toolbox is loaded and a compatible GPU is available to the program.
I know it is probably simple and the problem is I'm probably too simple to find it.
Thanks, Joe

Akzeptierte Antwort

Matt J
Matt J am 11 Nov. 2012
Maybe this
try
gpuArray(1);
canUseGPU=true;
catch
canUseGPU=false;
end

Weitere Antworten (1)

James Lebak
James Lebak am 16 Nov. 2012
Hi Joe,
There is not presently a function called 'canUseGPU' in Parallel Computing Toolbox. Matt's answer will work. You could also use the function parallel.gpu.GPUDevice.isAvailable instead of gpuArray, e.g.
try
canUseGPU = parallel.gpu.GPUDevice.isAvailable;
catch ME
canUseGPU = false;
end
James
  1 Kommentar
Joseph Areeda
Joseph Areeda am 16 Nov. 2012
Thanks James,
What I ended up doing was putting try catch around the gpuDevice function and also checking if enough memory is available for my job.
As with most programming problems once you get it it's obvious.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Parallel and Cloud finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by