> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phala.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GPU Policy

> Configure GPU attestation and DevTools mode for GPU CVMs, update policies on existing CVMs, and recover from GPU boot failures.

By default, a GPU CVM attests its GPUs through NVIDIA on every boot and includes the result in its [attestation](https://docs.phala.com/phala-cloud/attestation/overview.md). You can set a GPU policy in your app compose to skip GPU attestation on any GPU CVM (including H200), or to enable profiling and debugging tools on B200 and B300 GPUs.

GPU policies require a GPU instance type and dstack OS 0.6.0 or newer. The `phala gpu-policy` command requires Phala Cloud CLI 1.3.0-beta.1 or newer.

## How it works

A GPU policy is stored under `requirements.gpu_policy` in your app compose:

```json theme={"system"}
{ "requirements": { "gpu_policy": { "attest_gpu": false } } }
```

Phala Cloud stores this object verbatim in the compose. Because the compose is covered by the compose hash in the CVM's attestation, changing the policy produces a new compose hash that verifiers can check against the compose. If you omit `gpu_policy`, full GPU attestation runs by default.

## Configurations

| Configuration | `gpu_policy` | GPU mode | Effect |
| - | - | - | - |
| Default | *(none)* | Platform default | Full GPU attestation on every boot. |
| Attestation off | `{"attest_gpu": false}` | Platform default | The GPUs stay in confidential mode, but the CVM no longer checks this at boot and the attestation contains no GPU evidence. Useful for recovering from GPU attestation failures. |
| DevTools | `{"allow_devtools": true, "attest_gpu": false}` | DevTools (B200 and B300 only) | Enables NVIDIA profiling and debugging tools. GPU memory is **not** confidential and the attestation contains no GPU evidence. |

`{"attest_gpu": false}` works on all GPU instance types (including H200). Only DevTools changes the GPU mode, and only on B200 and B300 GPUs. On other GPUs, the DevTools policy keeps the normal confidential mode and works like attestation off.

By default, GPUs run with confidential computing enabled (or protected PCIe mode on 8-GPU H200 machines); disabling confidential computing altogether is not supported. Use DevTools only for development and profiling, never with private data.

Other supported keys have no CLI presets and must be passed as raw JSON via the API, `phala deploy --gpu-policy-file`, or `phala gpu-policy set --file` / `--stdin`:

* `allow_debug` (boolean): Not recommended; currently has no effect with the GPU attestation tool.
* `allow_insecure_boot` (boolean): Not recommended; currently has no effect with the GPU attestation tool.
* `rego` (string): A Rego v0 policy in `package policy` that defines the boolean rule `data.policy.nv_match`. Its input is the GPU attestation claims array. It also runs when `attest_gpu` is `false`, with an empty array as input, so a rule that requires GPU claims stops the CVM from booting. See the [dstack GPU security model](https://github.com/Dstack-TEE/dstack/blob/next/docs/security/security-model.md#gpu-security-for-ai-workloads).

## Eligibility

Only CVMs on a GPU instance type running dstack OS 0.6.0 or newer support a GPU policy:

* **CPU-only CVMs:** Sending a policy object fails with `ERR-03-075`. Sending `null` is always accepted so you can clear a mistakenly stored policy.
* **dstack OS 0.5.x:** Rejected unless you upgrade to dstack OS 0.6.0 or newer in the same request.

Because a GPU CVM cannot change its GPU type or count after creation, it remains eligible for its lifetime.

## Set a policy on create

### CLI

Pass `--gpu-policy` (`attestation-off` or `devtools`) to [`phala deploy`](https://docs.phala.com/phala-cloud/phala-cloud-cli/deploy):

```bash theme={"system"}
phala deploy -c docker-compose.yml --instance-type <gpu-instance-type> --gpu-policy attestation-off
```

To pass a custom JSON policy object from a file, use `--gpu-policy-file`:

```bash theme={"system"}
phala deploy -c docker-compose.yml --instance-type <gpu-instance-type> --gpu-policy-file gpu-policy.json
```

`--gpu-policy` and `--gpu-policy-file` are mutually exclusive, and neither can be combined with `--app-compose` (define `requirements.gpu_policy` directly in your app compose file instead).

### API

Include `requirements.gpu_policy` inside `compose_file` in `POST /cvms`:

```json theme={"system"}
{
  "compose_file": {
    "requirements": { "gpu_policy": { "allow_devtools": true, "attest_gpu": false } }
  }
}
```

Boolean fields must be JSON booleans (not strings). Unknown keys and empty `rego` strings fail with HTTP `422`.

## Update an existing CVM

Set or replace the policy with [`phala gpu-policy`](https://docs.phala.com/phala-cloud/phala-cloud-cli/gpu-policy) or [`PATCH /cvms/{cvm_id}`](https://docs.phala.com/phala-cloud/update/update-cvm-configuration):

```bash CLI theme={"system"}
phala gpu-policy set attestation-off --cvm-id <cvm-name-or-id>
```

```json API theme={"system"}
{ "compose": { "requirements": { "gpu_policy": { "attest_gpu": false } } } }
```

To remove the policy and return to full GPU attestation:

```bash CLI theme={"system"}
phala gpu-policy reset --cvm-id <cvm-name-or-id>
```

```json API theme={"system"}
{ "compose": { "requirements": { "gpu_policy": null } } }
```

You can also replace the policy on an existing CVM with `phala deploy --cvm-id <cvm-name-or-id> -c docker-compose.yml --gpu-policy-file gpu-policy.json`. To remove a policy, use `phala gpu-policy reset` (`phala deploy` has no reset flag).

### Replacement rules

Unlike other objects in `compose`, which merge key by key, `requirements.gpu_policy` is replaced as a whole on `PATCH /cvms/{cvm_id}`:

| Value sent for `gpu_policy` | Result |
| - | - |
| Policy object | Replaces the stored policy completely (keys are not merged). |
| `null` | Removes the policy and returns the CVM to the default. |
| Omitted | Keeps the stored policy unchanged. |

For example, if the stored policy is `{"allow_devtools": true, "attest_gpu": false}` and you patch with `{"attest_gpu": false}`, `allow_devtools` is dropped. Sending `"requirements": null` clears every key under `requirements`, including `gpu_policy`.

Passing `{}` or setting a field to `null` (such as `{"rego": null}`) fails with `422`. Send `"gpu_policy": null` to reset, or omit keys you do not want. Empty or whitespace-only `rego` strings are rejected on both create and update.

### Restarts, no-ops, and Onchain KMS

Updating the policy restarts a running CVM (stopping it, writing the new compose, and starting it again, which takes a few minutes). A stopped CVM stays stopped and picks up the new policy on its next start.

If the policy you send matches the stored policy's exact keys and values, nothing changes and the CVM does not restart. Because the comparison is literal rather than semantic, `{"attest_gpu": false}` and `{"attest_gpu": false, "allow_devtools": false}` produce different compose hashes and trigger a restart.

On Onchain KMS, register the new compose hash on your app contract before applying the update, just like any other compose change. See [What changes for a CVM on Onchain KMS?](https://docs.phala.com/phala-cloud/update/update-cvm-configuration.md#what-changes-for-a-cvm-on-onchain-kms).

### Staging with other changes

To combine a policy change with other updates in a single restart, stage it first and apply the draft together:

```bash theme={"system"}
phala gpu-policy set devtools --cvm-id <cvm-name-or-id> --stage
phala cvms draft apply <cvm-name-or-id>
```

If you stage multiple policy changes, the last one wins; staging `null` overrides an earlier staged policy so the policy is removed on apply. See [How do I stage several changes and restart once?](https://docs.phala.com/phala-cloud/update/update-cvm-configuration.md#how-do-i-stage-several-changes-and-restart-once).

## Inspect the current policy and GPU mode

```bash theme={"system"}
phala gpu-policy show --cvm-id <cvm-name-or-id>
```

This prints the stored policy, the configuration it matches, OS support status, and any staged policy change. It also prints the expected GPU mode alongside the host-observed mode (`Observed GPU mode`) for each GPU.

Check **Observed GPU mode** in `phala gpu-policy show` to see whether DevTools mode is active. Inside the CVM, `nvidia-smi conf-compute` shows the CC state as `ON` in both modes.

Via the API, read `compose_file.requirements.gpu_policy` from `GET /cvms/{cvm_id}`. Starting in API version `2026-11-11`, pass `include_compose=true` to include `compose_file` in the response.

## Recover from GPU boot failures

If GPU attestation fails at boot, the CVM does not finish booting. The node retries the boot a few times, then the CVM stays stopped. Because a stopped CVM still accepts policy updates, you can temporarily disable GPU attestation and start it again:

```bash theme={"system"}
phala gpu-policy set attestation-off --cvm-id <cvm-name-or-id> --yes
phala cvms start <cvm-name-or-id>
```

* If a start is still in progress, stop the CVM first with `phala cvms stop`, then run the two commands above.
* On Onchain KMS, register the new compose hash on your app contract before starting (the update will report it if missing).
* Once the underlying issue is resolved, run `phala gpu-policy reset` to restore full GPU attestation.

## Errors

| Error | Cause | Fix |
| - | - | - |
| `ERR-03-075` | Policy object sent for a CVM with no GPUs. | Use a GPU instance type, or send `null` to clear a stored policy. |
| `422` | Unknown key, wrong value type, `{}` in a PATCH, a `null` field value (such as `{"rego": null}`), or an empty `rego` string. | Fix the policy payload. To reset to the default, send `"gpu_policy": null`. |
| `ERR-03-053` | Staged changes were applied after the CVM's compose changed externally. | Discard the draft or re-apply against the current compose hash. See [What if the CVM changed after I staged?](https://docs.phala.com/phala-cloud/update/update-cvm-configuration.md#what-if-the-cvm-changed-after-i-staged). |

Requests targeting a CVM on dstack OS 0.5.x are also rejected. Upgrade to dstack OS 0.6.0 or newer first.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.