<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Vision",
  "identifier" : "/documentation/Vision/VisionRequest/setComputeDevice(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Vision"
    ],
    "preciseIdentifier" : "s:6Vision0A7RequestP16setComputeDevice_3fory6CoreML09MLComputeE0OSg_AA0D5StageOtF"
  },
  "title" : "setComputeDevice(_:for:)"
}
-->

# setComputeDevice(_:for:)

Assigns a compute device for a compute stage.

```
mutating func setComputeDevice(_ computeDevice: MLComputeDevice?, for computeStage: ComputeStage)
```

## 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. Use [`supportedComputeStageDevices`](/documentation/Vision/VisionRequest/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)