Skip to content
Snippets Groups Projects
Commit 4d1a5b62 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

GPU Check: fixed to work on non-Tesla cards

parent 09690caf
No related branches found
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment