<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Vision",
  "identifier" : "/documentation/Vision/VNRequest/setComputeDevice(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Vision"
    ],
    "preciseIdentifier" : "s:So9VNRequestC6VisionE16setComputeDevice_3fory6CoreML09MLComputeE0OSg_So14VNComputeStageatF"
  },
  "title" : "setComputeDevice(_:for:)"
}
-->

# setComputeDevice(_:for:)

Assigns a compute device for a compute stage.

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

## Parameters

`computeDevice`

The compute device to assign to the compute stage.

`computeStage`

The compute stage.

## 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`](/documentation/Vision/VNRequest/supportedComputeStageDevices) to get valid compute devices for a request’s compute stages.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)