| gpucapture(1) | General Commands Manual | gpucapture(1) |
gpucapture - CLI tool to produce GPU trace captures
gpucapture [--help] [--version] [--list-devices]
gpucapture boundary [--pid <PID>] [--device <ID>] [--help]
gpucapture start [--pid <PID>] [--boundary <BOUNDARY_ID>]
[--label <BOUNDARY_LABEL>]
[--count <BOUNDARY_COUNT>] [--output <FILEPATH>] [--device
<ID>] [--until-exit] [--help]
gpucapture stop [--pid <PID>] [--device <ID>] [--all] [--help]
gpucapture list [--help]
gpucapture is a command line tool for creating GPU Trace files for any App, process or service that can connect to GPU Tools agent/daemon gputoolsserviced. A GPU Trace file contains Metal (https://developer.apple.com/metal/) API calls (or other APIs such as MetalFX (https://developer.apple.com/documentation/metalfx)) as well as the necessary data to reconstruct any GPU workloads for further analysis via Metal Debugger (https://developer.apple.com/documentation/xcode/metal-debugger).
In order to establish a connection the user is responsible to launch their target process with MTL_CAPTURE_ENABLED=1 environment variable within. This environment variable is responsible for loading GPUToolsCapture.framework into the process and will attempt to connect to gputoolsserviced if a MTLDevice (https://developer.apple.com/documentation/metal/mtldevice) is ever created within the process.
list
List all capturable processes. When Xcode 15 or higher is running on the system, it will also display capturable processes of any remote device visible to Xcode.
boundary
List all capturable boundaries for a given PID. A boundary is an API call that is used by gpucapture as a trigger to begin/end a GPU Trace. Available boundary types:
start
Begins a GPU trace capture. If no arguments are provided this command will try a default behavior equivalent to gpucapture start --boundary DEFAULT_BOUNDARY_ID --count 1.
Produced GPU Trace is always stored in the local device filesystem.
stop
Ends a GPU trace capture. Options are used to help decide the scope for applying the stop command.
Any gpucapture in progress can also be stopped at any point in time via Ctrl+C
-h, --help
Show contextual help
-p, --pid <PID>
Capturable process PID for command to execute, if there are multiple PID available --device ID is required for disambiguation
-d, --device <ID>
Target device ID for command to execute at.
-b, --boundary <BOUNDARY_ID>
BOUNDARY_ID is the identifier of the trigger to use to begin/end a GPU Trace capture.
-l, --label <BOUNDARY_LABEL>
BOUNDARY_LABEL is used to identify a boundary API object instead of BOUNDARY_ID. If multiple objects share the same BOUNDARY_LABEL, gpucapture will be unable to define the target and will request the user to use --boundary BOUNDARY_ID instead. This option is especially useful for apps that do not have deterministic resource creation (random BOUNDARY_ID) but do label their objects. Only available for Queue, Layer or Scope.
-c, --count <BOUNDARY_COUNT>
BOUNDARY_COUNT is the amount of trigger ends that should be hit by the GPU trace capture before actually stopping it.
-u, --until-exit
This option is equivalent to --count UINT_MAX. Useful for capturing CLI workloads where the amount of CommandBuffers is not known as this allows the capture to progress until the process exits. Additionally, if you aim to control the gpucapture start of the process you should launch your target with MTLCAPTURE_WAIT_FOR_SIGNAL=1, this environment variable will halt the process on MTLDevice (https://developer.apple.com/documentation/metal/mtldevice) creation until a gpucapture start signal is registered.
-o, --output <FILEPATH>
FILEPATH on the host machine's file system, to where the recorded .gputrace will be stored.
, --version
Show tool version
, --list-devices
List available devices and exit. Shows an ID column that can be passed to --device, along with the device name, model, and OS version.
Retrieve a list of potential targets to capture.
Retrieve a list of boundaries available for the PID 12345.
Quick command to produce single frame/MTLCommandBuffer capture if there is a
single process available in `gpucapture list`.
Capture 5 times the boundary ID 3 in the process 12345
Captures 100000 times the default boundary ID in the process 12345. Default
boundary ID will be either a Layer or a Device.
Stops any active capture in the process 12345.
Stops any active capture in any capturable process visible by `gpucapture
list`.
| 300.20 |