> ## 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

> Show or change the GPU policy of a GPU CVM

## Command: `phala gpu-policy`

### Syntax

```bash theme={"system"}
phala gpu-policy <command> [options]
```

### Description

Show, set, or reset the GPU policy of a GPU CVM. Requires a GPU instance type, dstack OS 0.6.0 or newer, and Phala Cloud CLI 1.3.0-beta.1 or newer. See [GPU Policy](https://docs.phala.com/phala-cloud/cvm/gpu-policy.md) for full details on eligibility, compose hashing, and recovery.

Changing the policy updates the compose hash. A running CVM restarts (taking a few minutes); a stopped CVM stays stopped and picks up the new policy on its next start.

### Subcommands

| Command | Description |
| - | - |
| `show` | Print the stored policy, matched configuration, expected and observed GPU modes, and staged changes |
| `set` | Replace the GPU policy with a preset (`attestation-off`, `devtools`) or a JSON object |
| `reset` | Remove the GPU policy and return to full GPU attestation |

All subcommands resolve the target CVM from `--cvm-id`, `--interactive`, or the CVM ID in `phala.toml`.

### Supported 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}` (`attestation-off`) 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.

## Command: `phala gpu-policy show`

### Syntax

```bash theme={"system"}
phala gpu-policy show [options]
```

### Description

Prints the stored policy (or `not set`), the configuration it matches, OS support status, and any staged policy change. Also shows the expected and host-observed GPU mode for each GPU.

### Options

| Option | Description |
| - | - |
| `--cvm-id <value>` | CVM identifier (UUID, app\_id, instance\_id, or name) |
| `-j, --json` | Output in JSON format |
| `-i, --interactive` | Prompt to select a CVM interactively |

### Examples

* Show the current policy and GPU mode

```bash theme={"system"}
phala gpu-policy show --cvm-id my-cvm
```

## Command: `phala gpu-policy set`

### Syntax

```bash theme={"system"}
phala gpu-policy set [options] [<preset>]
```

### Description

Replaces the stored GPU policy as a whole without merging keys from the existing policy.

Pass one policy source (omit it when confirming a prepared Onchain KMS update with `--compose-hash`):

| Source | Payload sent |
| - | - |
| `attestation-off` | `{"attest_gpu": false}` |
| `devtools` | `{"allow_devtools": true, "attest_gpu": false}` |
| `--file <path>` | JSON object read from the file, verbatim |
| `--file -` or `--stdin` | JSON object read from stdin (requires `--yes`) |

Custom JSON input (`--file` or `--stdin`) is validated locally before sending. It must be a non-empty JSON object containing only boolean fields (`allow_debug`, `allow_devtools`, `allow_insecure_boot`, `attest_gpu`) or a non-empty Rego v0 policy string (`rego`, see the [dstack GPU security model](https://github.com/Dstack-TEE/dstack/blob/next/docs/security/security-model.md#gpu-security-for-ai-workloads)), with no `null` values. `{}` and `null` are rejected; use `phala gpu-policy reset` to return to the default.

The CLI compares exact keys and values against the stored policy. If they match, it prints `No change made.`, exits 0, and skips restarting the CVM. Because the comparison is literal, `{"attest_gpu": false}` and `{"attest_gpu": false, "allow_devtools": false}` produce different compose hashes and trigger a restart. An explicit default like `{"attest_gpu": true}` is also sent verbatim and produces a different compose hash than having no policy.

### Arguments

| Argument | Description |
| - | - |
| `<preset>` | Optional preset: `attestation-off` or `devtools` |

### Options

| Option | Description |
| - | - |
| `--file <path\|->` | Read the JSON policy object from a file, or from stdin with `-` (requires `--yes`) |
| `--stdin` | Read the JSON policy object from stdin (requires `--yes`) |
| `--cvm-id <value>` | CVM identifier (UUID, app\_id, instance\_id, or name) |
| `-j, --json` | Output in JSON format (requires `--yes`) |
| `-i, --interactive` | Prompt to select a CVM interactively |
| `--yes` | Skip the confirmation prompt. Required in non-interactive shells, with `--json`, or when reading from stdin |
| `--wait` | Wait for the update to finish, including on-chain finality when required |
| `--stage` | Stage the change in the CVM draft instead of applying immediately (apply later with `phala cvms draft apply`). Cannot be combined with `--wait`, `--prepare-only`, `--compose-hash`, or `--transaction-hash` |
| `--prepare-only` | Onchain KMS: prepare the update and print the compose hash without signing |
| `--compose-hash <value>` | Onchain KMS: confirm a prepared update. Use with `--transaction-hash` and without a policy source |
| `--transaction-hash <value>` | Onchain KMS: transaction hash that registered the compose hash, or `already-registered` |
| `--private-key <value>` | Onchain KMS: private key for signing (or set `PRIVATE_KEY`) |
| `--rpc-url <value>` | Onchain KMS: RPC URL (or set `ETH_RPC_URL`) |

### Examples

* Disable GPU attestation

```bash theme={"system"}
phala gpu-policy set attestation-off --cvm-id my-cvm
```

* Enable DevTools mode on B200/B300 and wait for restart

```bash theme={"system"}
phala gpu-policy set devtools --cvm-id my-cvm --wait
```

* Send a custom JSON policy from a file

```bash theme={"system"}
phala gpu-policy set --file gpu-policy.json --cvm-id my-cvm
```

* Read a custom JSON policy from stdin

```bash theme={"system"}
cat gpu-policy.json | phala gpu-policy set --stdin --yes --cvm-id my-cvm
```

* Stage the change and apply with other draft updates

```bash theme={"system"}
phala gpu-policy set devtools --cvm-id my-cvm --stage && phala cvms draft apply my-cvm
```

* Recover a CVM whose GPUs failed to start (run `phala cvms stop` first if a start is still in progress)

```bash theme={"system"}
phala gpu-policy set attestation-off --cvm-id my-cvm --yes && phala cvms start my-cvm
```

## Command: `phala gpu-policy reset`

### Syntax

```bash theme={"system"}
phala gpu-policy reset [options]
```

### Description

Removes `requirements.gpu_policy`, returning the CVM to full GPU attestation. Accepts the same options as `set`, without a policy source.

### Examples

* Return to the default policy

```bash theme={"system"}
phala gpu-policy reset --cvm-id my-cvm
```

## Setting the policy with `phala deploy`

You can also pass `--gpu-policy` or `--gpu-policy-file` to [`phala deploy`](https://docs.phala.com/phala-cloud/phala-cloud-cli/deploy) when creating or updating a CVM:

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


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