canUseGPU
Determine whether a compatible GPU is available.
📝Syntax
tf = canUseGPU()
📤Output Arguments
Parameter Description
tf logical: true when a compatible GPU device is available.
📄Description

tf = canUseGPU() returns true when a compatible GPU device is present and usable, and false otherwise (for example on a machine without a supported Vulkan, Metal or Direct3D 12 backend).

Use it to write code that runs on the GPU when possible and falls back to the CPU otherwise.

💡Examples
if canUseGPU()
  A = gpuArray(single(rand(1000)));
else
  A = single(rand(1000));
end
🔗See Also
gpuDevicegpuDeviceCount
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub