Low-Cost Edge AI: A Complete Tutorial for Deploying Local Large Language Models on ARM64 Single-Board Computers

    This tutorial explains how to deploy local large language models on low-cost ARM64 single-board computers. It covers hardware checks, resource estimation, Swap expansion, manual installation, systemd service management, model downloading, HTTP API verification, performance tuning, and common troubleshooting cases. It also discusses how to combine lightweight local inference with cloud inference when stronger model capabilities are needed.

    1. Introduction: Why Deploy Small Models at the Edge

    Single-board computers are usually based on the ARM64 (aarch64) architecture. They are small, low-power, and low-cost, and they often provide rich peripheral interfaces such as GPIO, cameras, and other I/O ports. These features make them suitable for scenarios such as home automation, edge data collection, and offline terminals.

    In recent years, on-device inference has attracted increasing attention. For small models with fewer than 1B parameters, the parameter count is small and the computational demand is relatively low. After the weights are compressed through quantization, a device with only a few GB of RAM can use the CPU to perform basic conversation and simple text processing. The main benefits are:

    • Offline availability: The local service can still respond when the network is unavailable.
    • Privacy control: Input data does not need to leave the device.
    • Predictable cost: Hardware is a one-time investment, and there are no usage-based inference charges.

    However, deploying a local inference runtime on a single-board computer is different from installing ordinary software on a server. In this article, the inference runtime refers to a service program that loads model weights, schedules computation, and exposes an interface to the outside world. The runtime frameworks discussed here generally follow this installation pattern: download the binary package for the target architecture, register it as a system service, download a model, and expose an interface.

    In practical deployments, three types of issues occur most frequently:

    1. Insufficient disk space during installation.
    2. Incorrect permission settings that prevent the service from accessing files.
    3. Background services repeatedly restarting.

    Many tutorials simply copy the one-click installation process designed for x86 environments. This approach ignores two important facts:

    • Single-board devices have limited storage and memory resources.
    • ARM64 platforms require architecture-specific binary packages.

    This article follows a controlled manual deployment approach and completes the process in five stages:

    1. Environment check.
    2. Swap expansion.
    3. Manual installation.
    4. Service hosting.
    5. Model execution and tuning.

    Each stage includes principles, operations, and verification methods.

    2. Stage 1: Environment Check — Can It Run?

    Before deployment, perform a basic environment check to avoid discovering resource limitations halfway through the process.

    2.1 Hardware Requirements and Resource Estimation

    Check Item Recommended Standard Command Description
    CPU architecture ARM64 (aarch64) uname -m Used to select the correct package version
    Available disk space ≥10 GB, more recommended df -h Must accommodate the runtime, model weights, and cache
    Physical memory ≥2 GB free -h Model weights generally need to stay resident in memory
    Swap At least equal to physical memory swapon --show, free -h An important buffer for memory-constrained systems

    In practice, storage is the most common bottleneck. There are three main reasons:

    • Official one-click scripts usually run with root privileges and write temporary files to the system temporary directory. Some devices mount that directory as a memory-backed filesystem, such as tmpfs. In that case, temporary files consume memory instead of disk, and the system may immediately report that there is no space left when memory is tight.
    • Model weights can range from hundreds of megabytes to several gigabytes. Additional space is also needed for upgrades and rollback, so planning only for the minimum usable space is usually insufficient.
    • If the device also runs resident processes such as databases or data collection programs, available resources can be reduced further.

    A simple estimation method is to reserve at least three times the size of the model weights on disk. This helps cover downloading, extraction, and caching. Therefore, 10 GB is a relatively safe starting point. For memory, when a model is loaded, the weights are first read fully into memory, and the resident memory usage is generally on the same scale as the quantized weight size. Increasing parallelism or context length will also increase cache usage.

    For example, a model with around 0.8B parameters and 4-bit quantization usually has weights of only a few hundred megabytes. On a device with 2 GB of RAM, it is reasonable to run with only one active request at a time.

    2.2 Swap Expansion: A Buffer When Memory Is Insufficient

    If the device has less than 2 GB of physical memory, or if a previous one-click installation failed with a message about insufficient space, it is recommended to expand Swap first.

    What Swap does

    Swap uses a portion of disk space as virtual memory. When physical memory is tight, the kernel swaps inactive memory pages out to that area to free up memory for current tasks. For deploying small-parameter models, Swap has two main benefits:

    1. It provides a peak buffer during model loading.
    2. It reduces the probability of processes being directly terminated when memory is exhausted.

    Operational suggestions

    • Space allocation: In general, allocate an amount equal to the physical memory and set a clear upper limit.
    • Location selection: Prefer expanded SSD storage. If only an SD card is available, Swap expansion should be treated only as a temporary emergency measure. Frequent swapping can accelerate write wear on the card.
    1. # 1. Create a 4GB swap file on a partition with enough free space. Adjust the path as needed.
    2. sudo fallocate -l 4G /swapfile
    3. # If the filesystem does not support fallocate, use:
    4. sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
    5. # 2. Restrict permissions to prevent ordinary users from reading swap data.
    6. sudo chmod 600 /swapfile
    7. # 3. Format the file as swap space and enable it.
    8. sudo mkswap /swapfile
    9. sudo swapon /swapfile
    10. # 4. Verify: if SIZE shows 4G, the swap is enabled successfully.
    11. swapon --show
    12. free -h

    After running swapon, the configuration is lost after a reboot unless it is added to the filesystem table. To persist it:

    1. # 5. Enable swap at boot. First make sure there is no existing /swapfile entry in /etc/fstab.
    2. echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

    If physical memory is sufficient and Swap was only needed temporarily for installation peak usage, it can be disabled afterward:

    1. sudo swapoff /swapfile
    2. # Also remove the corresponding entry from /etc/fstab

    Optional tuning: reduce swapping tendency

    Swap should be used as a safety margin, not as a second layer of memory. It is recommended to lower the swappiness value so the kernel keeps data in physical memory as much as possible and uses Swap only when memory is under pressure:

    1. # Range is 0 to 100. A lower value means the kernel is more likely to keep data in physical memory.
    2. sudo sysctl vm.swappiness=10
    3. # Make it permanent.
    4. echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swap.conf

    This preserves an emergency buffer while avoiding significant slowdowns caused by frequent disk swapping during model inference.

    3. Stage 2: Manual Installation — Control Every Step

    Once the environment is prepared, proceed to installation. Many users directly run official one-click scripts on single-board computers and frequently encounter errors. A more reliable approach is manual installation, because it makes the destination of each file, execution permissions, and failure reasons clear and traceable.

    3.1 Limitations of One-Click Scripts

    • Temporary files may be placed in memory: Intermediate steps such as extraction and verification may create temporary files in memory-backed temporary directories. Peak usage can be several times the size of the installation package, which is a typical cause of “insufficient space” errors.
    • Architecture matching is not always checked: Some scripts are designed primarily for x86 environments. On ARM64 devices, the binary may fail to execute and return an error such as Exec format error.
    • Failure messages may be too vague: When a script fails, the message may not clearly indicate whether the issue was a download interruption, a verification failure, or a permission restriction.

    3.2 Manual Installation Process

    Step 1: Download a package that matches the CPU architecture

    Use a directory with sufficient physical disk space, such as the user home directory, to download the release package that matches the CPU architecture:

    1. cd ~
    2. # The architecture has already been confirmed with uname -m. Here we use the arm64 package as an example.
    3. # Replace <download-url> with the official ARM64 package link from the runtime framework's release page.
    4. wget <download-url> -O runtime-arm64.tar.zst

    Step 2: Extract the package to a temporary directory

    First extract the package into a separate directory, then copy the contents as needed. This makes it easier to verify completeness and roll back quickly if something goes wrong:

    1. mkdir -p ~/runtime_temp
    2. # If the system reports that the compressed format is not recognized, Zstandard support may be missing.
    3. # You can install zstd through the system package manager first.
    4. sudo tar -I zstd -xf runtime-arm64.tar.zst -C ~/runtime_temp
    5. ls -l ~/runtime_temp

    Step 3: Copy files to the system path

    Place executable files and other necessary files in a system-level path so they can be called globally and managed by the service manager:

    1. sudo cp -r ~/runtime_temp/* /usr/local/
    2. # Confirm that the main executable has execute permissions.
    3. sudo chmod +x /usr/local/bin/ollama
    4. ollama --version

    Step 4: Clean up intermediate files

    1. rm -rf ~/runtime_temp ~/runtime-arm64.tar.zst

    3.3 Store Models on Disk

    By default, the runtime framework places model weights in a cache path under the user home directory. This path is usually located on the system disk, such as an SD card. It may have limited space, and it can be lost after reinstalling the system.

    If the device has a larger mounted storage volume, the model directory can be redirected using an environment variable in the service configuration. This has three benefits:

    • Model weights are separated from the system disk.
    • Migration becomes easier.
    • Reinstalling the system does not affect the models.
    1. # Example: point the model directory to a larger mount point.
    2. # The exact variable name depends on the framework documentation.
    3. export MODEL_DIR=/mnt/models
    4. mkdir -p /mnt/models

    4. Stage 3: Register a Systemd Service for Stable Background Operation

    Processes started manually in the foreground can be interrupted when the terminal closes or when an exception occurs. If the runtime is managed by the systemd service manager, it can start automatically on boot, restart automatically after an abnormal exit, and collect logs in a unified way.

    4.1 Create a Dedicated System Account

    The service should run under a dedicated account with minimal privileges. Even if the process is compromised, the impact remains limited:

    1. # -r creates a system account, -s /bin/false disables login, and -d sets the home directory.
    2. sudo useradd -r -s /bin/false -m -d /usr/share/ollama ollama
    3. # Ensure the account has read and write access to the model directory.
    4. sudo chown -R ollama:ollama /mnt/models

    4.2 Create the Service Configuration File

    Create the service configuration file using a text editor:

    1. [Unit]
    2. Description=Local LLM Runtime Service
    3. After=network-online.target
    4. Wants=network-online.target
    5. [Service]
    6. User=ollama
    7. Group=ollama
    8. # Listen address. The default binds only to localhost, which is more secure.
    9. Environment="OLLAMA_HOST=127.0.0.1:11434"
    10. # Model weight storage path. The variable name depends on the framework.
    11. Environment="OLLAMA_MODELS=/mnt/models"
    12. ExecStart=/usr/local/bin/ollama serve
    13. Restart=always
    14. RestartSec=3
    15. [Install]
    16. WantedBy=multi-user.target
    • After=network-online.target ensures that the service starts after the network is ready.
    • Restart=always and RestartSec=3 cause the service to restart automatically 3 seconds after it exits.

    4.3 Enable and Verify the Service

    1. sudo systemctl daemon-reload # Reload configuration
    2. sudo systemctl enable ollama # Enable startup on boot
    3. sudo systemctl start ollama # Start the service immediately
    4. sudo systemctl status ollama # Check status; confirm active (running)

    4.4 Why the Service Keeps Failing to Start

    If the service fails to start, the problem is often not with the program itself, but with a missing prerequisite in the runtime environment. Check the following table:

    Symptom Common Cause Check and Fix
    Status is failed, and the log says a file cannot be found The installation path does not match, or the executable permission is missing Check the ExecStart path and add chmod +x if needed
    The log reports permission denied The service account does not have write permission for the model or log directory Adjust ownership or add the account to the appropriate group
    The service repeatedly restarts after a few seconds The process may have been terminated because memory was insufficient Check kernel logs for OOM records; expand Swap or reduce concurrency
    The port is already in use Another process using the same framework or an old service is already running Check the port usage, stop the old service, or change the listening port
    The log reports a format error The package for the wrong architecture was downloaded Confirm the architecture with uname -m and download the correct package
    The log reports request timeout The default address only allows local access, and external connections are rejected For cross-device access, adjust the listening address and configure authentication

    After modifying the configuration, remember to run daemon-reload again. To view real-time logs, use:

    1. journalctl -u ollama -f

    4.5 Security Note: Do Not Expose the Service Address Casually

    To make it easier for other devices to call the service, some users change the listening address from localhost to all network interfaces. If the environment does not have authentication enabled, this is effectively exposing an unauthenticated interface to the entire local network.

    The following practices are recommended:

    • By default, bind only to the loopback address.
    • If cross-device access is truly required, add authentication through a reverse proxy and use firewall rules to restrict source network ranges.
    • Do not map the port to the public internet.
    • Do not print sensitive request content in logs.

    5. Stage 4: Pull a Small-Parameter Model and Verify It

    Once the service is running, use the built-in command to pull a model. 0.8b is an example of how parameter scale appears in the model tag. Replace it with the actual tag you need:

    1. ollama pull qwen3.5:0.8b
    2. ollama list # Confirm the model is available
    3. ollama run qwen3.5:0.8b # Enter interactive conversation

    If the download is slow or frequently interrupted, you can obtain the model files from an external mirror and import them manually. When importing, specify a template that matches the quantization level.

    Choosing quantization precision

    Quantization Level Relative Size Memory Pressure Suitable Scenario
    FP16 (original precision) Baseline High Memory-rich validation scenarios with high precision requirements
    8-bit About half Medium General use where quality and resource usage need to be balanced
    4-bit About one quarter Low Memory-limited single-board devices and lightweight Q&A

    A 0.8B-parameter model has limited capacity by itself. With 4-bit quantization, it can run smoothly on devices with around 2 GB of memory. For daily Q&A, text summarization, and simple instruction following, the precision loss is usually acceptable.

    Quick verification through the HTTP API

    Instead of entering the interactive interface, you can verify the service directly through its HTTP API. The following example uses a non-streaming, one-time request:

    1. curl http://127.0.0.1:11434/api/generate -d '{
    2. "model": "qwen3.5:0.8b",
    3. "prompt": "Explain edge computing in one sentence.",
    4. "stream": false
    5. }'

    In the response, the response field contains the model output. eval_count is the number of tokens generated in this request, and eval_duration is the time from the start of generation to the end, measured in nanoseconds. Dividing these values gives the measured generation speed, which can be used for later comparisons with tuning results.

    6. Stage 5: Performance Tuning for Single-Board Devices

    6.1 Four Adjustable Dimensions

    • Parallelism and thread count: Single-board computers usually have only 4 to 8 CPU cores. Too many parallel requests can cause resource contention and make the overall system slower. It is recommended to first set num_thread to the number of physical cores, test the result, and then adjust gradually.
    • Context length: The longer the context, the more cache memory is used. For daily Q&A, 2048 to 4096 is usually enough, and there is no need to increase it blindly.
    • Quantization precision: When resources are tight, prioritize 4-bit quantization. A small amount of precision can be traded for stability.
    • Keeping the model resident in memory: Keeping the model in memory can avoid latency caused by frequent loading, but this must be balanced against idle memory usage.

    6.2 Runtime Observability Metrics

    • Memory usage: Use free -h and process-level monitoring.
    • Temperature: Excessive temperature can trigger throttling, causing inference speed to drop suddenly.
    • API response time: Measure using P50/P95 percentiles instead of only looking at the average.
    • Service status: Check with systemctl status and monitor the error rate in logs.

    6.3 Common Issues Quick Reference

    Issue Handling Method
    The process disappears during inference Usually caused by insufficient memory and process termination. Expand Swap or reduce concurrency.
    Speed fluctuates Check whether high temperature triggers throttling. Add a heatsink or fan if necessary.
    The service fails to start after an upgrade Check whether the new version’s service configuration is compatible. If necessary, roll back to the previous version.
    The device becomes unresponsive and requires a power cycle Check whether the power adapter has enough output power. Too many peripherals can also cause insufficient power supply.

    7. Conclusion and Further Directions

    This tutorial follows five stages: environment check, Swap expansion, manual installation, service hosting, model execution, and tuning. It is a reproducible method for deploying local large language models on ARM64 single-board computers.

    The core ideas can be summarized as follows:

    1. Assess resources in advance: Most installation failures are not caused by the program itself, but by unmet prerequisites related to disk space, permissions, or memory.
    2. Keep the process controllable: Manual installation makes the destination of each file clear, allowing problems to be located quickly.
    3. Host the service properly: Let the runtime framework run in the background with automatic startup and automatic restart capabilities.

    If stronger model capabilities or multi-device coordination are needed later, an edge-cloud hybrid approach can also be used. The single-board computer can handle lightweight local inference and data preprocessing, while more complex tasks such as long-text understanding and multimodal processing can be handed off to cloud inference services. The two sides can connect through a unified gateway or message queue, balancing cost, latency, and privacy.

    For further exploration, readers can also try the following:

    • Convert quantized models into device-native inference formats to improve execution efficiency.
    • Use containerization to package the service and its environment dependencies together.
    • Integrate monitoring and alerting systems to continuously observe service availability.

    When edge hardware cannot meet the requirements for larger-parameter models or higher concurrency, Baidu AI Cloud provides model services with elastic inference compute. For example, on the Baidu AI Cloud Qianfan platform, you can select or deploy a model, obtain an API key, and call the model over HTTP. It can then be connected as the cloud-side backend to a local gateway, forming a tiered inference architecture of “lightweight edge model + stronger cloud model.”