---
title: "setComputeDevice(_:for:)"
framework: vision
role: symbol
role_heading: Instance Method
path: "vision/vnrequest/setcomputedevice(_:for:)"
---

# setComputeDevice(_:for:)

Assigns a compute device for a compute stage.

## Declaration

```swift
@nonobjc func setComputeDevice(_ computeDevice: MLComputeDevice?, for computeStage: VNComputeStage)
```

## Parameters

- `computeDevice`: The compute device to assign to the compute stage.
- `computeStage`: The compute stage.

## Discussion

Discussion If the parameter computeDevice is nil, the framework removes any explicit compute device assignment and allows the framework to select the device. Configure any compute device for a given compute stage. When performing a request, the system makes a validity check. Call supportedComputeStageDevices to get valid compute devices for a request’s compute stages.

## See Also

### Configuring the Compute Device

- [computeDevice(for:)](vision/vnrequest/computedevice(for:).md)
- [supportedComputeStageDevices](vision/vnrequest/supportedcomputestagedevices.md)
