From 4d1a5b62a3db045a1f692629027c1f4a52573b80 Mon Sep 17 00:00:00 2001 From: Nicola Vigano <nicola.vigano@esrf.fr> Date: Thu, 11 Apr 2013 14:58:44 +0200 Subject: [PATCH] GPU Check: fixed to work on non-Tesla cards Signed-off-by: Nicola Vigano <nicola.vigano@esrf.fr> --- 5_reconstruction/gtCheckGpu.m | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/5_reconstruction/gtCheckGpu.m b/5_reconstruction/gtCheckGpu.m index 0d073d1e..df56a150 100644 --- a/5_reconstruction/gtCheckGpu.m +++ b/5_reconstruction/gtCheckGpu.m @@ -1,7 +1,22 @@ function gpu_ok = gtCheckGpu() - [status, out] = unix('nvidia-smi | grep Tesla'); - if ~status && length(out) > 10 - gpu_ok = true; - else - gpu_ok = false; + % First get list of GPUs + [ret_code, msg] = unix('nvidia-smi -L'); + if (ret_code) + disp('No nVidia driver installed!') + gpu_ok = false; + return; + end + % It could be both UUID and S/N, so ".+?" matches both + gpus = regexp(msg, '\(.+?: (?<uuid>.*?)\)', 'names'); + + % Now Let's find a GPU which is not attached to a monitor + for ii = 1:numel(gpus) + [~, msg] = unix(['nvidia-smi -q -i ' gpus(ii).uuid]); + displayMode = regexp(msg, 'Display Mode\s*: (?<mode>.*?)\n', 'tokens'); + if (strcmp(displayMode{1}, 'Disabled')) + gpu_ok = true; + return; + end + end + gpu_ok = false; end -- GitLab