---
title: gpu()
framework: ML Compute
role: symbol
role_heading: Type Method
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+]
path: mlcompute/mlcdevice/gpu()
---

# gpu()

Creates a device that uses a GPU, if one exists.

## Declaration

```swift
class func gpu() -> Self?
```

## Return Value

Return Value A device that uses a GPU, or nil if no GPU exists.

## See Also

### Creating Devices

- [init(type:)](mlcompute/mlcdevice/init(type:).md)
- [init(type:selectsMultipleComputeDevices:)](mlcompute/mlcdevice/init(type:selectsmultiplecomputedevices:).md)
- [MLCDeviceType](mlcompute/mlcdevicetype.md)
- [init(gpuDevices:)](mlcompute/mlcdevice/init(gpudevices:)-4mj85.md)
- [cpu()](mlcompute/mlcdevice/cpu().md)
- [ane()](mlcompute/mlcdevice/ane().md)
