> This page is for version 0.6.0.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.sandbox.utils

Sandbox utility helpers.

## Module Contents

### Functions

| Name                                                     | Description                                                             |
| -------------------------------------------------------- | ----------------------------------------------------------------------- |
| [`cpu_cap_env`](#nemo_gym-sandbox-utils-cpu_cap_env)     | CPU\_CAP\_ENV\_VARS derived from a sandbox CPU limit; empty when unset. |
| [`read_text`](#nemo_gym-sandbox-utils-read_text)         | Download UTF-8 text, replacing invalid bytes in partial process output. |
| [`rewrite_image`](#nemo_gym-sandbox-utils-rewrite_image) | Apply ordered image-prefix rewrites used by sandbox configs.            |
| [`upload_text`](#nemo_gym-sandbox-utils-upload_text)     | Upload UTF-8 text through file transfer without shell interpolation.    |

### Data

[`CPU_CAP_ENV_VARS`](#nemo_gym-sandbox-utils-CPU_CAP_ENV_VARS)

### API

```python
nemo_gym.sandbox.utils.cpu_cap_env(
    cpu: float | int | None
) -> dict[str, str]
```

CPU\_CAP\_ENV\_VARS derived from a sandbox CPU limit; empty when unset.

```python
nemo_gym.sandbox.utils.read_text(
    sandbox: nemo_gym.sandbox.api.AsyncSandbox,
    path: str
) -> str
```

async

Download UTF-8 text, replacing invalid bytes in partial process output.

```python
nemo_gym.sandbox.rewrite_image(
    image: str | None,
    rewrites: list[dict[str, str]]
) -> str | None
```

Apply ordered image-prefix rewrites used by sandbox configs.

```python
nemo_gym.sandbox.utils.upload_text(
    sandbox: nemo_gym.sandbox.api.AsyncSandbox,
    path: str,
    text: str
) -> None
```

async

Upload UTF-8 text through file transfer without shell interpolation.

```python
nemo_gym.sandbox.utils.CPU_CAP_ENV_VARS: tuple[str, ...] = ('OMP_NUM_THREADS', 'OMP_THREAD_LIMIT', 'OPENBLAS_NUM_THREADS', 'MKL_NUM_THREADS...
```