Deploying Local LLMs with an AI Application Platform: From Installation to Connectivity
This guide walks through deploying a local large language model with Ollama and connecting it to a containerized AI application platform. It covers how to estimate VRAM requirements and choose a model size, install and verify Ollama on Windows or Linux, pull models and validate inference, deploy an application stack with Docker Compose, configure networking so containers can reach the host's model service, and tune performance with measurable baselines. Each step includes executable commands and troubleshooting tips for common failures such as insufficient VRAM, port conflicts, and API errors.
Deploying Local LLMs with an AI Application Platform: From Installation to Connectivity
The most common blockers when running a local LLM alongside an AI application platform are insufficient VRAM, containers failing to reach the model service, and API errors. This article follows the actual order of operations, providing executable commands, verifiable parameters, and a troubleshooting approach.
Audience: Developers with Windows or Linux experience and basic Docker knowledge.
1. Estimate Hardware First, Then Choose a Model
1.1 How to Estimate VRAM
Whether a model can run depends primarily on GPU VRAM. When VRAM is insufficient, part of the computation falls back to system memory and CPU, and speed drops noticeably. Weight size can be roughly estimated as “parameter count × bytes per parameter.” FP16 uses about 2 bytes per parameter, INT8 about 1 byte, and common 4-bit quantization (such as Q4_K_M, the default in Ollama) uses about 0.5–0.6 bytes per parameter.
| Model size | FP16 weights | INT8 weights | 4-bit quantized weights | Recommended VRAM (4-bit, 4K context) |
|---|---|---|---|---|
| 7B / 8B | ~14–16 GB | ~7–8 GB | ~4.5–5 GB | 8 GB works, with little headroom |
| 14B | ~28 GB | ~14 GB | ~9 GB | 12–16 GB |
| 32B | ~64 GB | ~32 GB | ~19–20 GB | 24 GB |
These are estimates. Actual usage also includes 1–2 GB of runtime buffer plus KV cache, which grows with context length. Raising the context from 4K to 32K can add several GB of KV cache, depending on model architecture. Always confirm with readings from ollama ps and nvidia-smi.
1.2 Choosing a System
On Windows, you can install the Ollama desktop app directly—simple to use and good for quick validation. If you later want consistency with a Linux server deployment, install the Linux version of Ollama inside WSL 2. Running Ollama typically requires only the GPU driver, not the full CUDA toolkit. After installing the driver, run nvidia-smi in a terminal; seeing the GPU model and driver version confirms the driver works.
2. Install Ollama and Verify
2.1 Installation
Download the installer for your system from the official Ollama website (ollama.com). Windows users can double-click OllamaSetup.exe. Linux users can use the official install script—download and read it before running:
curl -fsSL https://ollama.com/install.sh | sh
2.2 Verify the Version
On Windows, press Win + R, type cmd, and press Enter to open a command line, then run:
ollama -v
Output containing ollama version and a version number confirms a successful install. If you get “not recognized as an internal or external command,” close and reopen the terminal so the new PATH takes effect. If it still fails, check whether the install directory is in your user PATH, or rerun the installer.
2.3 Model Directory and Disk Space
On Windows, Ollama stores models in %USERPROFILE%\.ollama\models by default. On Linux, the path depends on the install method—commonly ~/.ollama/models or /usr/share/ollama/.ollama/models. A 7B model takes several GB; 14B and 32B models take more. If your system drive is tight on space, set the OLLAMA_MODELS environment variable to another drive, e.g., D:\ollama\models, then restart Ollama.
3. Pull a Model and Verify Inference
3.1 Pull and Run
Choose a model version based on the VRAM table in Section 1. Using the 7B-class Qwen2.5 as an example:
ollama pull qwen2.5:7bollama run qwen2.5:7b "Introduce yourself in one sentence"
After the pull completes, run ollama list to see local models and their sizes. Once the model is loaded into VRAM, run ollama ps and check the PROCESSOR column. 100% GPU means the model runs entirely on the GPU. Something like 48%/52% CPU/GPU means VRAM is insufficient and some layers are in system memory, so inference will be slower.
3.2 Verify File Integrity
Ollama model files are named by their sha256 and stored in the blobs subdirectory of the model directory; checksums are verified automatically during pulls. If you download a GGUF model file from another source, find the sha256 value on the download page and compare it locally:
- Windows:
certutil -hashfile <filename> SHA256 - Linux:
sha256sum <filename>
Only use the file if the two values match.
3.3 Licenses
Licenses vary across models and even across sizes of the same model. Some allow commercial use; others limit user scale or require attribution. Before commercial use or offering a service externally, check the License terms on each model’s page.
3.4 Common Issues
| Symptom | Likely cause | Fix |
|---|---|---|
| Download interrupted or timed out | Unstable network or proxy required | Rerun ollama pull; Ollama supports resuming. If a proxy is needed, set HTTPS_PROXY and restart Ollama |
| First response is very slow | Model loading into VRAM for the first time | Normal behavior; observe subsequent response speed |
| Slow responses, high CPU usage | Insufficient VRAM, some layers on CPU | Confirm the ratio with ollama ps; switch to a smaller model or quantization, or reduce context length |
| Out of memory or CUDA-related errors | Insufficient VRAM or driver issue | Use a smaller model; run nvidia-smi to check the driver |
4. Containerized Deployment of an AI Application Platform
4.1 Prerequisites
Windows requires Docker Desktop; Linux requires Docker Engine and the Compose plugin. After installation, verify versions:
docker --versiondocker compose version
4.2 Check Port Conflicts
If the platform fails to start, first check whether host ports are occupied. On Windows:
netstat -ano | findstr :8080
On Linux:
ss -lntp | grep :8080
If the port is taken, the output shows the process ID. Either stop the program using the port, or change the host port in the compose file—for example, change "8080:8080" to "18080:8080".
4.3 Example Configuration
The compose file below is a generic template, not tied to any vendor. Before using it, replace image with the official image of your chosen platform, and use the variable names from that platform’s documentation. Sensitive values such as database passwords should go in a .env file in the same directory as the compose file, and must not be committed to a code repository.
services:app:image: <your-platform-image>:<tag>ports:- "8080:8080"environment:MODEL_API_BASE: http://host.docker.internal:11434/v1MODEL_API_KEY: ${MODEL_API_KEY}extra_hosts:- "host.docker.internal:host-gateway"depends_on:- postgres- redisvolumes:- ./data/app:/app/datapostgres:image: postgres:16environment:POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}volumes:- ./data/pg:/var/lib/postgresql/dataredis:image: redis:7
4.4 Startup, Logs, and Backup
Before changing configuration, back up the data directory and compose file. On Linux:
cp -r ./data ./data.bak
On Windows, copy via File Explorer or run xcopy data data.bak /E /I.
Start the services and check status:
docker compose up -ddocker compose psdocker compose logs -f app
Initialization failures typically fall into three categories. First, database connection failure: check that the postgres container is running and that the password in .env matches the application configuration. Second, data directory permissions: on Linux, if the mounted directory has the wrong owner, postgres may fail to write; run sudo chown -R 999:999 ./data/pg, where 999 is the default user ID in the official postgres image. Third, image pull failures: check proxy settings or the image registry.
5. Connecting the Pieces
5.1 Containers Accessing the Host’s Model Service
Inside a container, localhost refers to the container itself, not the host. Therefore, the model address in the platform configuration should use host.docker.internal. Docker Desktop supports this hostname natively; on Linux it relies on the extra_hosts entry in the compose template above.
First confirm Ollama responds on the host:
curl http://127.0.0.1:11434/api/tags
Windows 10 and later ship with curl.exe. A returned model list means the service is healthy.
Then test from inside a container. If the application image lacks curl, run a temporary test container:
docker run --rm --add-host=host.docker.internal:host-gateway curlimages/curl http://host.docker.internal:11434/api/tags
5.2 Listen Address and Security Prerequisites
By default, Ollama listens only on 127.0.0.1:11434, accessible only from the host itself. To let containers reach it, you must change the listen address. This step widens the service’s exposure, so the following conditions must be met first:
- Use only on a trusted internal network; never expose it to the public internet.
- In the firewall, allow only the container subnet or trusted hosts to access port 11434.
- Ollama itself provides no authentication. If other hosts need access, put an authenticating reverse proxy in front of it.
On Windows: add a system environment variable OLLAMA_HOST with value 0.0.0.0:11434, then quit Ollama from the system tray and restart it.
On Linux, if Ollama was installed via systemd, run sudo systemctl edit ollama and add:
[Service]Environment="OLLAMA_HOST=0.0.0.0:11434"
Save, then run sudo systemctl restart ollama.
After the change, confirm the listen scope. On Windows run netstat -ano | findstr 11434; on Linux run ss -lntp | grep 11434. If it shows 0.0.0.0:11434, the service is exposed on all interfaces.
To roll back: on Windows, delete the OLLAMA_HOST environment variable; on Linux, remove the systemctl edit override, then restart Ollama. After rolling back, run the listen check again to confirm the address is back to 127.0.0.1:11434.
5.3 API Protocol and Timeouts
Ollama provides an API compatible with OpenAI Chat Completions. In the platform, set the model address to:
http://host.docker.internal:11434/v1
The platform’s actual request path is /chat/completions, i.e., the full URL is /v1/chat/completions. Example request body:
{"model": "qwen2.5:7b","messages": [{"role": "user", "content": "Hello"}]}
The model field must exactly match a name shown in ollama list. Common errors:
- 404: the address is missing
/v1, or the path is wrong. - 400: the model name doesn’t exist, or request parameters are malformed.
- If the platform requires an API Key: local Ollama doesn’t validate keys, so any non-empty string works.
For 14B and larger models, time-to-first-token can reach tens of seconds. Set the platform’s timeout to 120 seconds or longer, otherwise it will disconnect before the model responds.
6. Performance Tuning and Heterogeneous Compute
6.1 Test Matrix
Establish a baseline before tuning parameters. Use a fixed set of prompts, repeat each configuration three times, and take the median to reduce interference from first-load effects. Tunable variables and metrics to observe:
| Variable | Values | Metrics |
|---|---|---|
| Context length (num_ctx) | 2K, 4K, 8K | Peak VRAM, time to first token |
| Concurrency (OLLAMA_NUM_PARALLEL) | 1, 2, 4 | Tokens per second, peak VRAM |
| Quantization | Q4, Q8 | Answer quality, VRAM usage |
How to measure: ollama run --verbose <model> outputs load time, prompt processing rate, and generation rate (eval rate). Peak VRAM can be sampled once per second with nvidia-smi --query-gpu=memory.used --format=csv -l 1.
Note that as concurrency increases, each concurrent request occupies its own KV cache, so VRAM usage rises accordingly. Tune concurrency and context length together rather than chasing throughput alone.
6.2 Combining with Cloud Services
Local model files are large and can be backed up periodically to cloud object storage. Stop the Ollama service before backing up to avoid copying files while they’re being written. Cloud monitoring can also periodically request /api/tags to check service liveness and alert after consecutive failures.
6.3 Heterogeneous Compute
Compatibility of domestic (non-NVIDIA/AMD) accelerator cards depends on the vendor-provided drivers, operator libraries, and inference engine versions. Ollama’s officially supported acceleration backends are mainly NVIDIA, AMD, and similar. Whether other hardware works should be confirmed against the vendor’s official compatibility list and inference engine documentation. Before a full migration, run the entire pipeline with the same small model first, then gradually switch to the target model.
Conclusion
Deploying a local LLM with an AI application platform comes down to three things: choose a model based on VRAM, confirm Ollama runs properly on the host, and let containers reach the model service via the correct address, listen scope, and API path. Every step can be verified independently with the commands in this article; when problems arise, troubleshoot in order and you can usually locate the cause quickly.
