# Fractional GPUs: when a slice is all you need



Learn how to optimize ML costs and performance by using fractional GPUs for inference and development tasks through memory management and Podstack’s GPU cloud.



Infrastructure · 2026-08-31 · 4 min read



The rapid evolution of Large Language Models (LLMs) and diffusion models has created a massive surge in demand for high-end hardware. However, not every machine learning task requires the full brute force of an H100 or an A100. In many production scenarios, allocating an entire 80GB GPU to a single small task is like using a sledgehammer to crack a nut—it’s inefficient and expensive.

This is where fractional GPUs come in. By slicing a single physical GPU into multiple logical units, ML engineers can maximize resource utilization, reduce latency for concurrent requests, and significantly cut operational costs.

## Why Slice Your Compute?

In a traditional setup, a GPU is treated as a monolithic resource. If your model only uses 4GB of VRAM and 15% of the CUDA cores, the remaining 90%+ of the hardware sits idle, yet you are billed for the full unit. Fractional GPUs solve this through two primary methods:

1.  **Memory Mapping:** Restricting the amount of VRAM a process can see or allocate.
2.  **Time-Slicing/MIG:** Partitioning the hardware at the driver or hardware level so multiple containers can run in parallel on one card.

For tasks like preprocessing, small-scale inference (e.g., BERT or Whisper), and dev environments, fractional GPUs allow you to scale horizontally without your budget scaling linearly.

## When a Slice is All You Need

Before you partition your resources, identify if your workload fits the "fractional" profile. Good candidates include:

*   **Serverless Inference:** Handling intermittent traffic for lightweight models where a dedicated GPU would spend 90% of its time idling.
*   **Microservices:** Running multiple specialized models (one for OCR, one for sentiment, one for summarization) on a single physical machine.
*   **Development & Prototyping:** Giving every developer on a team a "slice" of a powerful GPU rather than one developer hogging the whole machine.
*   **CI/CD Pipelines:** Running automated tests for GPU-accelerated code.

## Implementing Fractional Inference

If you are deploying via Python, you can manage memory consumption directly to allow multiple processes to coexist. Below is a practical example of how to initialize a model with strict memory limits using `torch`.

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

def load_model_fractional(model_name: str, memory_fraction: float):
    # Set the fraction of the GPU memory to be used by this process
    # memory_fraction is a float between 0.0 and 1.0
    torch.cuda.set_per_process_memory_fraction(memory_fraction, device=0)
    
    print(f"Allocated {memory_fraction * 100}% of GPU for this worker.")
    
    tokenizer = AutoTokenizer.from_pretrained(model_name)
    model = AutoModelForCausalLM.from_pretrained(
        model_name,
        device_map="cuda:0",
        torch_dtype=torch.float16
    )
    return model, tokenizer

# Example: Use only 25% of the GPU for this specific inference worker
model, tokenizer = load_model_fractional("gpt2", 0.25)
```

By setting `set_per_process_memory_fraction`, you prevent a single Python process from greedily grabbing all available VRAM, allowing you to spin up four identical workers on the same physical chip.

## Practical Tips for Fractional Workloads

*   **Monitor "Cold Starts":** When using fractional units in a serverless context, ensure your container images are optimized. Smaller images mean faster loading onto the sliced hardware.
*   **Watch the Interconnect:** While compute is sliced, the PCIe bandwidth is shared. If you have four slices all trying to move massive datasets from RAM to VRAM simultaneously, you may hit a bottleneck.
*   **Right-size your VRAM:** Don't just guess. Use profiling tools to see the peak memory usage of your model during a heavy inference request, then add a 20% buffer. If your model peaks at 6GB, an 8GB slice is your sweet spot.

## Deploying on Podstack

Podstack makes fractional GPU management seamless by abstracting the hardware complexity. Instead of manually configuring NVIDIA partitions, you can define your resource requirements directly through the Podstack API.

With Podstack, you only pay for the compute you actually consume, billed by the second. If you need a Python function to run on a fraction of a GPU for a specific job, you can deploy it instantly.

First, ensure your environment is ready:

```bash
export PODSTACK_API_KEY="your_secret_key_here"
```

You can then deploy a fractional GPU worker by specifying the resource requirements in your deployment manifest or via the API:

```text
Podstack does not ship a command-line interface. Use the console, the Python package `podstack-sdk`, or the API at https://podstack.ai/api/v1 with a `ps_live_` key.
```

Podstack’s orchestration layer handles the bin-packing, ensuring that multiple "slices" are efficiently packed onto our high-performance GPU fleet. This means you get the power of enterprise-grade hardware without the enterprise-grade price tag for small tasks.

## Conclusion

Maximizing GPU ROI is a core competency for modern ML teams. By moving away from the "one model, one GPU" mindset and embracing fractional slices, you can build more resilient, scalable, and cost-effective AI applications. Whether you are running serverless inference or batch processing jobs, remember: sometimes, a slice is all you really need.
