Getting the Default GPU

Select the system's default GPU device on which to run your Metal code.


To use the Metal framework, you start by getting a GPU device. All of the objects your app needs to interact with Metal come from a MTLDevice that you acquire at runtime. iOS and tvOS devices have only one GPU that you access by calling MTLCreateSystemDefaultDevice:

guard let device = MTLCreateSystemDefaultDevice() else { 
    fatalError( "Failed to get the system's default Metal device." ) 

On macOS devices that are built with multiple GPUs like Macbook, the system default is the discrete GPU. However, you may want to choose other GPU device(s) for fine-grained control. See Choosing GPUs on Mac for more information.

See Also

GPU Devices


The Metal interface to a GPU that you use to draw graphics or do parallel computation.

Choosing GPUs on Mac

Select one or more GPUs on which to run your Metal code by considering GPU capabilities, power, or performance characteristics.