> ## Documentation Index
> Fetch the complete documentation index at: https://cerebrium-fix-make-entrypoint-docs-explicit.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CPU and Memory

## Overview

CPU and memory resources on Cerebrium are allocated per container and billed based on actual usage. Each app can be configured with specific CPU and memory requirements to optimize performance and cost.

## Resource Configuration

### CPU Configuration

CPU resources are specified as vCPU units (float) in the `cerebrium.toml` file:

```toml theme={null}
[hardware]
cpu = 4    # Number of vCPU cores
```

For most applications, starting with 4 CPU cores is recommended. Additional cores can be added based on monitoring, performance, and resource requirements. CPU usage is throttled when exceeding the specified limit. It is also possible to request a fractional CPU (e.g., `0.5`).

### Memory Configuration

Memory is specified in gigabytes as a floating-point number:

```toml theme={null}
[hardware]
memory = 16.0    # Memory in GB
```

A general guideline is to allocate system memory equal to the GPU's VRAM capacity. This accounts for initial model loading and compilation before GPU transfer. Applications will terminate with an Out of Memory (OOM) error if they exceed the specified memory limit.

<Info>
  Memory and CPU are billed based on usage, which reduces costs for end-users
  and doesn’t require the overprovisioning of an entire instance.
</Info>

## Resource Limits

Resource limits depend on the selected hardware configuration:

| Hardware Type | Max CPU Cores | Max Memory (GB) |
| ------------- | ------------- | --------------- |
| CPU Only      | 48            | 96              |
| ADA\_L40      | 16            | 128             |
| AMPERE\_A100  | 12            | 140             |
| AMPERE\_A10   | 48            | 192             |
| ADA\_L4       | 48            | 192             |
| TURING\_T4    | 48            | 192             |
| HOPPER\_H100  | 24            | 256             |
| TRN1          | 128           | 512             |
| INF2          | 192           | 796             |

## Memory Optimization

The Transformers library provides memory optimization through the `low_cpu_mem_usage` flag, which reduces memory-footprint at the cost of longer initialization times. Implementing lazy loading for large datasets can further optimize memory usage. Regular monitoring of memory patterns through platform metrics helps identify optimization opportunities. Memory-efficient model loading techniques should be considered for large-scale deployments.

## Resource Monitoring

The platform monitors CPU utilization and throttling events to help identify performance bottlenecks. Memory usage and OOM events are tracked to prevent application failures.

## Support

The Cerebrium team encounters projects of all shapes and sizes and is confident in supporting teams through the optimization of app resources and architecture for cost and performance. Join our [Discord](https://discord.gg/ATj6USmeE2) community or reach out to [support@cerebrium.ai](mailto:support@cerebrium.ai) with any questions.
