function n = gpuDeviceCount
%GPUDEVICECOUNT - return how many GPU devices are present
%   N = GPUDEVICECOUNT returns how many GPU devices are present in your
%   system. gpuDeviceCount only counts GPU devices supported by your
%   graphics driver.
%
%   See also gpuDevice, parallel.gpu.GPUDevice, parallel.gpu.CUDADevice.

% Copyright 2010-2018 The MathWorks, Inc.

% This can't be allowed to fail. If CUDA isn't available or there's some
% other problem we catch it and return 0
try
    n = parallel.internal.gpudeviceinfo.gpuDeviceCount;
catch err %#ok<NASGU>
    n = 0;
end
