Local Deployment Guide for Lightweight LLMs: Installation, Storage, and Performance Testing

    This guide walks through deploying a lightweight large language model locally using Ollama, covering hardware and model selection, engine installation and verification, model download and storage path configuration, quantization formats, and a repeatable approach to performance testing and troubleshooting. It uses llama3.2:3b as the example model and explains how to estimate VRAM requirements, move models to a different disk, measure generation speed, and resolve common issues such as insufficient VRAM, port conflicts, and encoding problems.

    1. Hardware and Model Selection

    Before deploying locally, confirm three types of resources: VRAM, system RAM, and disk space. Whether the model fits entirely in VRAM directly determines inference speed. When VRAM is insufficient, some layers stay in system memory and performance drops noticeably.

    Estimating model footprint is straightforward: multiply the parameter count by the bytes per parameter, then add the context cache (KV cache) and runtime overhead. With a common 4-bit quantization format such as Q4_K_M, each parameter takes roughly 0.5 bytes. That means a 3B model’s weights occupy about 2 GB, and 7B to 8B models occupy about 4 to 5 GB. In practice, reserve an extra 1 to 2 GB; the longer the context, the larger the cache.

    Use this checklist when selecting a model:

    • VRAM: enough to hold the model weights, plus 1 to 2 GB of headroom.
    • Quantization format: prefer Q4_K_M or Q5_K_M for a good balance of accuracy and size.
    • Context length: set only what your workload requires; larger defaults consume more memory.
    • License: confirm the model permits your intended use, such as commercial use or redistribution.
    • Disk: reserve about twice the model size to allow for downloads, migration, and rollback.

    This article uses Ollama as the inference engine. It supports Windows, macOS, and Linux, and can pull quantized models directly from the official model library. The example model is llama3.2:3b, suitable for machines with 6 GB or more of VRAM. With 8 GB of VRAM, you can try quantized 7B to 8B models.

    2. Installing the Inference Engine and Verifying It

    Windows users can download the installer OllamaSetup.exe from the Ollama website and run it. Alternatively, use winget in PowerShell:

    1. winget install --id Ollama.Ollama -e

    macOS users can download the official app or install via Homebrew:

    1. brew install ollama

    Linux users can use the official installation script. Before running it, open the script in a browser and review its contents:

    1. curl -fsSL https://ollama.com/install.sh | sh

    After installation, close and reopen the terminal so the PATH takes effect. On Windows, an icon appears in the system tray and the service runs in the background.

    Verification has two steps. First, check the CLI version:

    1. ollama --version

    Success means the terminal prints a version string like ollama version is 0.x.x. Second, confirm the background service is listening on its default port, 11434:

    1. curl http://localhost:11434/api/version

    Success means it returns a JSON response containing a version field. If both steps pass, the CLI and the service are working.

    3. Model Download, Storage Path, and Quantization

    Pull the model and list installed models:

    1. ollama pull llama3.2:3b
    2. ollama list

    ollama pull downloads the model from the official library and verifies the digest of each file. If the download is interrupted, simply run the command again. ollama list shows installed models and their sizes.

    By default, models are stored under the user directory, for example %USERPROFILE%\.ollama\models on Windows. As the number of models grows, the system drive fills up quickly, so it is advisable to move the model directory to another disk. Do this by setting the OLLAMA_MODELS environment variable.

    On Windows:

    1. Open “Edit the system environment variables”, create a new user variable OLLAMA_MODELS, and set its value to D:\LocalModels.
    2. Right-click the Ollama icon in the system tray to quit, then restart the app so the variable takes effect.
    3. Run ollama pull llama3.2:3b and confirm that new files appear in the directory on the D drive.

    On Linux with systemd, run sudo systemctl edit ollama.service and add:

    1. [Service]
    2. Environment="OLLAMA_MODELS=/data/ollama/models"

    Save, then run sudo systemctl daemon-reload and sudo systemctl restart ollama. The ollama user must have read and write permissions on the new directory; set this with sudo chown -R ollama:ollama /data/ollama/models.

    Before migrating existing models, back up the old directory. Copy the blobs and manifests subdirectories intact to the new location, then run ollama list and ollama run to confirm the models work. Only delete the old files after verification. Do not delete individual files inside blobs during migration, or the models will be corrupted.

    Quantization formats are selected through model tags. Run ollama show llama3.2:3b to view the parameter count, quantization type, and context length—review this before choosing a model.

    4. Performance Testing Methodology and Troubleshooting

    Performance numbers are only meaningful when the test conditions are stated. Record at least four items: the model and quantization format, context length, hardware model, and measurement tool.

    To measure, run the model with the --verbose flag:

    1. ollama run llama3.2:3b --verbose

    Enter a fixed prompt; after the response completes, the terminal prints statistics. Focus on three metrics: load duration is model loading time, prompt eval rate is input processing speed, and eval rate is generation speed in tokens/s. Run the same prompt at least three times and average the last two runs to avoid the first-load effect.

    Run ollama ps to see which device the model is running on. If the PROCESSOR column shows 100% GPU, all layers are on the GPU. A mixed CPU/GPU ratio indicates insufficient VRAM and reduced speed. In that case, switch to a smaller model or reduce the context length.

    Common issues and fixes:

    Insufficient VRAM: switch to a smaller model or a lower-bit quantization. Reducing the context length via the API’s num_ctx parameter or a Modelfile also lowers VRAM usage.

    Port in use, with an address already in use error at startup: identify the process occupying the port. Alternatively, set the OLLAMA_HOST environment variable to use a different port and update the client configuration accordingly.

    Command not found: the terminal was not reopened after installation, so PATH has not been updated. Restart the terminal and run the version command again.

    Slow model loading: the first load reads weights from disk. Placing models on an NVMe SSD and avoiding heavy programs during loading reduces wait time.

    Garbled non-ASCII output: the Windows terminal’s default encoding may not be UTF-8. Run chcp 65001 in PowerShell to switch the encoding, and decode output as UTF-8 in your programs.

    Models disappear after changing the storage path: usually the environment variable did not take effect. Check the spelling of the variable value and confirm the service was fully exited before restarting.

    5. Multi-Device Distribution (Optional)

    After completing single-machine deployment, if you need the same model version on multiple devices, you can place the model files in your own storage center. Common options include an internal file server or a NAS.