What does the gpuInfo function do in MATLAB / RunMat?
gpuInfo() returns a concise, human-readable string that summarises the active GPU acceleration
provider. It is a convenience wrapper around gpuDevice, intended for logging or
displaying status information in the REPL and notebooks.
How does the gpuInfo function behave in MATLAB / RunMat?
- Queries the same device metadata as
gpuDevice()and formats the fields intoGPU[key=value, ...]. - Includes identifiers (
device_id,index), descriptive strings (name,vendor,backend) and capability hints (precision,supports_double,memory_byteswhen available). - Escapes string values using MATLAB-style single quote doubling so they are display-friendly.
- When no acceleration provider is registered, returns the placeholder string
GPU[no provider]instead of throwing an error, making it safe to call unconditionally. - Propagates unexpected errors (for example, if a provider fails while reporting metadata) so they can be diagnosed.
GPU residency in RunMat (Do I need gpuArray?)
gpuInfo is a pure metadata query and never changes residency. Arrays stay wherever they already
live (GPU or CPU). Use gpuArray, gather, or RunMat Accelerate's auto-offload heuristics to move
data between devices as needed.
Examples of using the gpuInfo function in MATLAB / RunMat
Displaying GPU status in the REPL
disp(gpuInfo());
Expected output (in-process provider):
GPU[device_id=0, index=1, name='InProcess', vendor='RunMat', backend='inprocess', precision='double', supports_double=true]
Emitting a log line before a computation
fprintf("Running on %s\n", gpuInfo());
Expected output:
Running on GPU[device_id=0, index=1, name='InProcess', vendor='RunMat', backend='inprocess', precision='double', supports_double=true]
Checking for double precision support quickly
summary = gpuInfo();
if contains(summary, "supports_double=true")
disp("Double precision kernels available.");
else
disp("Falling back to single precision.");
end
Handling missing providers gracefully
% Safe even when acceleration is disabled
status = gpuInfo();
if status == "GPU[no provider]"
warning("GPU acceleration is currently disabled.");
end
Combining gpuInfo with gpuDevice for structured data
info = gpuDevice();
summary = gpuInfo();
if isfield(info, 'memory_bytes')
fprintf("%s (memory: %.2f GB)\n", summary, info.memory_bytes / 1e9);
else
fprintf("%s (memory: unknown)\n", summary);
end
Expected output (when the provider reports memory_bytes):
GPU[device_id=0, index=1, name='InProcess', vendor='RunMat', backend='inprocess', precision='double', supports_double=true] (memory: 15.99 GB)
If the provider omits memory metadata, the fallback branch prints:
GPU[device_id=0, index=1, name='InProcess', vendor='RunMat', backend='inprocess', precision='double', supports_double=true] (memory: unknown)
FAQ
Does gpuInfo change GPU state?
No. It only reads metadata and formats it into a string.
Will gpuInfo throw an error when no provider is registered?
No. It returns GPU[no provider] so caller code can branch without exception handling.
How is gpuInfo different from gpuDevice?
gpuDevice returns a struct that you can inspect programmatically. gpuInfo formats the same
information into a single string that is convenient for logging and display.
Does the output order of fields stay stable?
Yes. Fields are emitted in the same order as the gpuDevice struct: identifiers, descriptive
strings, optional metadata, precision, and capability flags.
Are strings escaped in MATLAB style?
Yes. Single quotes are doubled (e.g., Ada'GPU becomes Ada''GPU) so the summary can be pasted
back into MATLAB code without breaking literal syntax.