What Causes a Local AI Runtime to Load Duplicate Model Copies?

Eva Wong is the Technical Writer and resident tinkerer at ZimaSpace. A lifelong geek with a passion for homelabs and open-source software, she specializes in translating complex technical concepts into accessible, hands-on guides. Eva believes that self-hosting should be fun, not intimidating. Through her tutorials, she empowers the community to demystify hardware setups, from building their first NAS to mastering Docker containers.

Duplicate model copies appear when separate processes, replicas, sessions, or device contexts cannot share one loaded weight allocation.

A home AI server may show roughly twice the expected RAM or VRAM after adding a web UI, background worker, voice service, document indexer, or second API endpoint. The model file on disk can remain singular while several runtime objects hold independent weights, converted tensors, prepacked kernels, caches, and device contexts. Some duplication is accidental; other copies are deliberate replicas created for concurrency, isolation, or parallel execution.

One Model File Can Produce Several Independent Runtime Objects

Loading from the same path does not imply that two applications reference one in-memory model. Each runtime instance can parse the checkpoint and allocate its own tensors.

Google Cloud’s inference guidance distinguishes configurations that load one model copy per process or per virtual machine.

If memory rises in model-sized increments as worker count increases, the main cause is instance replication. Smaller increases point more strongly toward per-worker caches, allocators, or execution contexts.

Web Servers and Job Workers Often Start Separate Processes

A frontend server, queue consumer, scheduler, transcription service, and RAG worker may each import the model loader even when they belong to one Compose stack.

Process isolation gives every service its own address space. CPU pages can sometimes be shared through operating-system mechanisms, but ordinary framework objects and GPU allocations are not automatically one shared model service.

The duplication follows process IDs and service boundaries. If stopping one container releases approximately one model copy, the container was not merely forwarding requests to a central runtime.

Serving Replicas Are Individual Copies by Design

Autoscaling systems increase throughput by starting more replicas. A replica is an independent worker capable of serving requests when other workers are busy.

Ray Serve defines replicas as individual copies running in separate actor processes.

Memory growth that tracks traffic spikes or autoscaler events is intentional replication rather than a leak. The cause is the chosen concurrency model, even if the extra replicas later take time to scale down.

-15% OFF
Single board computer zimaboard2

Multiple Inference Sessions Can Duplicate Initializers and Prepacked Weights

An application can create several sessions inside one process for different threads, endpoints, profiles, or execution providers.

ONNX Runtime documents sharing allocators, initializers, and prepacked weights across sessions because separate sessions otherwise add memory overhead.

If one process owns several session objects and memory increases when each session initializes, the duplicate state exists inside the application rather than across containers.

Forking Does Not Guarantee Shared Accelerator Weights

A parent process may load a model before creating workers and appear to share CPU pages through copy-on-write. Accelerator initialization and mutable runtime state complicate that assumption.

PyTorch’s multiprocessing guidance explains that tensors can use shared-memory mechanisms across processes, but sharing requires an explicit compatible design.

A worker that moves the model to the GPU, changes weights, builds a cache, or initializes after spawn can allocate a new copy even if the original CPU checkpoint pages were shared.

Separate CUDA Contexts Add Per-Process Device State

Two processes using one GPU normally operate through distinct CUDA contexts unless a special sharing architecture is used.

NVIDIA notes that multiple CUDA application processes generally create multiple contexts with memory overhead.

Context overhead is not a second full model by itself, but it can accompany duplicated weights, kernels, workspaces, and caches. Memory increases smaller than the checkpoint size may therefore still come from process duplication.

Two Runtime Instances on One GPU Reserve Memory Independently

A dashboard can start one model server while an automation service starts another, both pointing to the same checkpoint and device.

vLLM documents that GPU-memory utilization is a per-instance limit and gives the example of two instances dividing one GPU’s capacity.

If each endpoint has its own listener, logs, scheduler, and KV cache, the two processes are independent inference engines. A shared model directory prevents duplicate downloads, not duplicate runtime allocations.

Reloads Can Leave an Old Process Alive Beside the New One

Hot reloaders, supervisors, rolling updates, failed shutdowns, and health-check restarts can start a replacement before the old worker releases its model.

This cause appears as a temporary or persistent pair of nearly identical processes with different start times. Requests may reach only the newer process while the older one continues holding RAM or VRAM.

ZimaSpace’s article on why to separate AI runtime state from model files provides the boundary: one checkpoint cache can serve many deployments, but the service topology still determines how many loaded copies exist.

FAQ

Does one model file on disk mean only one copy is in RAM?

No. Several processes or sessions can independently read the same file and allocate their own tensors, caches, and execution state.

Is every extra copy a memory leak?

No. Replicas, tensor-parallel workers, fallback runtimes, and isolated services may intentionally allocate additional state. A leak grows without a corresponding live runtime object.

Can containers share one GPU model automatically?

No. Containers can access the same device and files, but they need a shared serving process or explicit interprocess design to reuse one loaded model allocation.

Tech & AI HUB

More to Read

Get More Builds Like This

Stay in the Loop

Get updates from Zima - new products, exclusive deals, and real builds from the community.

Stay in the Loop preferences

We respect your inbox. Unsubscribe anytime.