GPU Acceleration
This page covers how to use LocalAI with GPU acceleration across different hardware vendors. For container image tags and registry details, see Container Images. For memory management with multiple GPU-accelerated models, see VRAM Management.
Automatic Backend Detection
When you install a model from the gallery (or a YAML file), LocalAI intelligently detects the required backend and your system’s capabilities, then downloads the correct version for you. Whether you’re running on a standard CPU, an NVIDIA GPU, an AMD GPU, or an Intel GPU, LocalAI handles it automatically.
For advanced use cases or to override auto-detection, you can use the LOCALAI_FORCE_META_BACKEND_CAPABILITY environment variable. Here are the available options:
default: Forces CPU-only backend. This is the fallback if no specific hardware is detected.nvidia: Forces backends compiled with CUDA support for NVIDIA GPUs.amd: Forces backends compiled with ROCm support for AMD GPUs.intel: Forces backends compiled with SYCL/oneAPI support for Intel GPUs.
Model configuration
Depending on the model architecture and backend used, there might be different ways to enable GPU acceleration. It is required to configure the model you intend to use with a YAML config file. For example, for llama.cpp workloads a configuration file might look like this (where gpu_layers is the number of layers to offload to the GPU):
For diffusers instead, it might look like this instead:
Multi-GPU Support
llama.cpp
For llama.cpp models, you can control which GPU layers are offloaded using gpu_layers. When multiple NVIDIA GPUs are present, llama.cpp distributes layers across available devices automatically. You can control GPU visibility with the CUDA_VISIBLE_DEVICES environment variable:
For AMD GPUs, use HIP_VISIBLE_DEVICES instead:
llama.cpp tensor split (lower latency on several NVIDIA GPUs)
llama.cpp has two useful ways to split one model across GPUs. Set the mode with the split_mode option:
| Mode | What it does | Use it when |
|---|---|---|
layer (default) | Each GPU holds a block of whole layers. A token goes through the GPUs one after the other. | The model does not fit on one GPU and you want fast prompt processing or many parallel requests. Works on any interconnect. |
tensor | Each layer is split across all GPUs, with its KV cache. The GPUs work on every token together and exchange results after each layer. | You want the fastest token generation for one or few requests. Experimental upstream. Needs a fast GPU interconnect. |
Use this configuration as a starting point for tensor:
What to know before you use it:
- Fit the model yourself. llama.cpp’s auto-fit is not implemented for tensor split. With
fit_paramsleft on, llama.cpp logs that it cannot fit and loads with the values you gave. If the load runs out of GPU memory, lowercontext_sizefirst, thenparallel, and only thengpu_layers(layers on the CPU are much slower). - Not every architecture supports it. The load fails with
LLAMA_SPLIT_MODE_TENSOR not implemented for architecture '...'for many MoE, hybrid and state-space families (for example DeepSeek2, Nemotron-H, Granite-Hybrid, Jamba, Mamba, Minimax-M2) and for some others (OLMo2, Gemma-3n, T5). Usesplit_mode:layerfor those. Upstream keeps the full list in llama.cpp’s multi-GPU guide. - KV cache type. The example uses
f16.bf16andf32also work. The llama.cpp version that LocalAI ships also accepts quantized KV cache (q8_0, …) with tensor split; check the output quality if you use it. tensor_splitgives the share of each GPU, in the order llama.cpp lists the devices ("3,1"puts 75% on the first GPU). Use it when the GPUs have different memory sizes.- Validate the output. Upstream marks tensor split as experimental. Compare a few answers with
split_mode:layerbefore you rely on it.
NCCL. In tensor mode the GPUs add up partial results after every layer. On NVIDIA GPUs llama.cpp does this with NCCL (NVIDIA Collective Communications Library) when the backend has it, and with its own slower code when it does not. The CUDA 12 and CUDA 13 llama-cpp backends for x86_64, and the CUDA 13 backend for arm64, ship NCCL in the backend’s lib/ directory, so there is nothing to install. The Jetson (CUDA 12 arm64) backend does not ship it, because NVIDIA does not provide NCCL for Jetson. NCCL is only used when a model runs with split_mode:tensor on two or more GPUs. With one GPU, or with layer split, nothing changes.
If NCCL cannot start (for example when CUDA virtual devices are in use), llama.cpp logs a warning and uses its own code. These environment variables of llama.cpp change the behavior. Set them on the LocalAI process or container, and the backend inherits them:
| Variable | Effect |
|---|---|
GGML_CUDA_ALLREDUCE=internal | Do not use NCCL; use llama.cpp’s own code (it supports exactly two GPUs and falls back further otherwise). Useful to compare speed with and without NCCL. |
GGML_CUDA_ALLREDUCE=none | Use the simplest generic fallback. For troubleshooting only. |
GGML_CUDA_P2P=1 | Let the GPUs copy data directly to each other. Usually faster, but it needs driver support and can crash or corrupt output on some motherboards (for example with IOMMU on). Remove it if you see problems. |
NCCL is distributed under the BSD-3-Clause license. Its notice is in licenses/NCCL-LICENSE.txt in the backend directory.
diffusers
For multi-GPU support with diffusers, configure the model with tensor_parallel_size set to the number of GPUs you want to use.
The tensor_parallel_size parameter is set in the gRPC proto configuration (in ModelOptions message, field 55). When this is set to a value greater than 1, the diffusers backend automatically enables device_map="auto" to distribute the model across multiple GPUs.
Tips
- For optimal performance, use GPUs of the same type and memory capacity.
- Ensure you have sufficient GPU memory across all devices.
- When running multiple models concurrently, consider using VRAM Management to automatically unload idle models.
CUDA(NVIDIA) acceleration
Requirements
Requirement: nvidia-container-toolkit (installation instructions 1 2)
If using a system with SELinux, ensure you have the policies installed, such as those provided by nvidia
To check what CUDA version do you need, you can either run nvidia-smi or nvcc --version.
Alternatively, you can also check nvidia-smi with docker:
docker run --runtime=nvidia --rm nvidia/cuda:12.8.0-base-ubuntu24.04 nvidia-smiTo use CUDA, use the images with the cublas tag, for example.
The image list is on quay:
- CUDA
12tags:latest-gpu-nvidia-cuda-12,master-gpu-nvidia-cuda-12,v5.1.1-gpu-nvidia-cuda-12 - CUDA
13tags:latest-gpu-nvidia-cuda-13,master-gpu-nvidia-cuda-13,v5.1.1-gpu-nvidia-cuda-13
In addition to the commands to run LocalAI normally, you need to specify --gpus all to docker, for example:
If the GPU inferencing is working, you should be able to see something like:
5:22PM DBG Loading model in memory from file: /models/open-llama-7b-q4_0.bin
ggml_init_cublas: found 1 CUDA devices:
Device 0: Tesla T4
llama.cpp: loading model from /models/open-llama-7b-q4_0.bin
llama_model_load_internal: format = ggjt v3 (latest)
llama_model_load_internal: n_vocab = 32000
llama_model_load_internal: n_ctx = 1024
llama_model_load_internal: n_embd = 4096
llama_model_load_internal: n_mult = 256
llama_model_load_internal: n_head = 32
llama_model_load_internal: n_layer = 32
llama_model_load_internal: n_rot = 128
llama_model_load_internal: ftype = 2 (mostly Q4_0)
llama_model_load_internal: n_ff = 11008
llama_model_load_internal: n_parts = 1
llama_model_load_internal: model size = 7B
llama_model_load_internal: ggml ctx size = 0.07 MB
llama_model_load_internal: using CUDA for GPU acceleration
llama_model_load_internal: mem required = 4321.77 MB (+ 1026.00 MB per state)
llama_model_load_internal: allocating batch_size x 1 MB = 512 MB VRAM for the scratch buffer
llama_model_load_internal: offloading 10 repeating layers to GPU
llama_model_load_internal: offloaded 10/35 layers to GPU
llama_model_load_internal: total VRAM used: 1598 MB
...................................................................................................
llama_init_from_file: kv self size = 512.00 MBROCM(AMD) acceleration
There are a limited number of tested configurations for ROCm systems. The hipblas images are built on ROCm 10.1, which AMD’s compatibility matrix lists for the Instinct accelerators (gfx908, gfx90a, gfx942, gfx950), the Radeon RDNA2/3/4 cards (gfx1030, gfx1100, gfx1101, gfx1102, gfx1200, gfx1201) and the Ryzen APUs (gfx1103, gfx1150, gfx1151, gfx1152, gfx1153). The Python backends are the exception: they bring their own ROCm 7.x runtime with the PyTorch ROCm wheel (see Limitations).
Due to the nature of ROCm it is best to run all implementations in containers as this limits the number of packages required for installation on host system, compatibility and package versions for dependencies across all variations of OS must be tested independently if desired, please refer to the build documentation.
Requirements
- A GPU/accelerator that the ROCm 10.1 compatibility matrix lists
- A host OS and
amdgpukernel driver that the same matrix lists as compatible with ROCm 10.1. The ROCm user space comes with the image; the host only needs the kernel driver (amdgpu-dkmsor the in-treeamdgpuof a supported kernel).
Recommendations
- Make sure to do not use GPU assigned for compute for desktop rendering.
- Ensure at least 100GB of free space on disk hosting container runtime and storing images prior to installation.
AMD Strix Halo / gfx1151 (RDNA 3.5)
AMD Ryzen AI MAX+ (Strix Halo) APUs with an integrated Radeon 8060S (gfx1151 / RDNA 3.5) are
supported with ROCm 7.11.0+, and gfx1151 is an officially supported target of ROCm 10.1, which the
hipblas images use. These systems provide up to 96 GB of unified VRAM accessible by the GPU.
Tested on: Geekom A9 Mega (AMD Ryzen AI MAX+ 395, ROCm 7.11.0, Ubuntu 24.04, kernel 6.14).
Required kernel boot parameters (add to GRUB_CMDLINE_LINUX in /etc/default/grub, then run update-grub):
iommu=pt amdgpu.gttsize=126976 ttm.pages_limit=32505856Required environment variables for gfx1151:
| Variable | Value | Purpose |
|---|---|---|
HSA_OVERRIDE_GFX_VERSION | 11.5.1 | Tells the HSA runtime to use gfx1151 code objects. Only for images built on a ROCm release that does not know gfx1151 natively; the ROCm 10.1 images do not need it |
ROCBLAS_USE_HIPBLASLT | 1 | Prefer hipBLASLt over rocBLAS for GEMM (required for gfx1151) |
HSA_XNACK | 1 | Enable XNACK (memory-fault retry) for APU unified memory |
HSA_ENABLE_SDMA | 0 | Disable SDMA engine: causes hangs on APU/iGPU configs |
Warning: Do not set
GGML_CUDA_ENABLE_UNIFIED_MEMORY. The C-level check isgetenv(...) != nullptr, so even=0activateshipMallocManaged(allocates from system RAM instead of the 96 GB VRAM pool).
Running LocalAI on gfx1151 (use the standard ROCm/hipblas image; there is only one ROCm image, and it ships with ROCm 10.1 by default):
Note: When updating the image, always recreate the container (
docker compose up --force-recreate) rather than just restarting it.docker compose restartpreserves the old container environment and will not pick up updated env vars from the image.
For llama.cpp models, enable flash attention (--flash-attention) for best performance on APU systems. Leave mmap unset in the model configuration: llama.cpp then loads without mmap on devices that do not support it, such as APUs. Set mmap: false to force this on any device.
Limitations
Ongoing verification testing of ROCm compatibility with integrated backends. Please note the following list of verified backends and devices.
LocalAI hipblas images are built against the following targets: gfx908, gfx90a, gfx942, gfx950, gfx1030, gfx1100, gfx1101, gfx1102, gfx1103, gfx1150, gfx1151, gfx1152, gfx1153, gfx1200, gfx1201
The Python backends (diffusers, transformers, vllm, coqui, …) are built on ROCm 7.2.1 and use the PyTorch ROCm wheels from download.pytorch.org/whl/rocm7.0. Their GPU support is that of the wheel, not the list above; PyTorch does not publish ROCm 10.1 wheels yet. To build a backend for another ROCm release, see Choosing the ROCm release for hipblas builds.
Note: Starting with ROCm 6.4, AMD removed rocBLAS kernel support for older architectures (gfx803, gfx900, gfx906). Since llama.cpp and other backends depend on rocBLAS for matrix operations, these GPUs (e.g. Radeon VII) are no longer supported in pre-built images.
The images and backends do not include other targets, and the container cannot rebuild them at startup. If your device is not one of the above targets, build the backend from source with AMDGPU_TARGETS set to your gfx target. See Build backends. This does not help for architectures that lack rocBLAS kernel support in your ROCm version.
Verified
The devices in the following list have been tested with hipblas images.
| Backend | Verified | Devices | ROCm Version |
|---|---|---|---|
| llama.cpp | yes | MI100 (gfx908), MI210/250 (gfx90a) | 7.x |
| llama.cpp | yes | Radeon 8060S / gfx1151 (Strix Halo) | 7.11.0 |
| diffusers | yes | MI100 (gfx908), MI210/250 (gfx90a) | 7.x |
| whisper | no | none | - |
| coqui | no | none | - |
| transformers | no | none | - |
| vllm | no | none | - |
You can help by expanding this list.
System Prep
- Check your GPU LLVM target is compatible with the version of ROCm. This can be found in the LLVM Docs.
- Check which ROCm version is compatible with your LLVM target and your chosen OS (pay special attention to supported kernel versions). See the ROCm compatibility matrix.
- Install your chosen version of the
dkmsandrocm(it is recommended that the native package manager be used for this process for any OS as version changes are executed more easily via this method if updates are required). Take care to restart after installingamdgpu-dkmsand before installingrocm, for details regarding this see the ROCm installation documentation. - Deploy. Yes it’s that easy.
Setup Example (Docker/containerd)
The following are examples of the ROCm specific configuration elements required.
The same can also be executed as a run for your container runtime
docker run \
-e LOCALAI_LOG_LEVEL=debug \
--device /dev/dri \
--device /dev/kfd \
quay.io/go-skynet/local-ai:master-gpu-hipblasPlease ensure to add all other required environment variables, port forwardings, etc to your compose file or run command.
Example (Kubernetes)
For k8s deployments there is an additional step required before deployment, this is the deployment of the ROCm/k8s-device-plugin. For any k8s environment the documentation provided by AMD from the ROCm project should be successful. It is recommended that if you use rke2 or OpenShift that you deploy the SUSE or RedHat provided version of this resource to ensure compatibility. After this has been completed the helm chart from go-skynet can be configured and deployed mostly un-edited.
The following are details of the changes that should be made to ensure proper function.
While these details may be configurable in the values.yaml development of this Helm chart is ongoing and is subject to change.
The following details indicate the final state of the localai deployment relevant to GPU function.
This configuration has been tested on a ‘custom’ cluster managed by SUSE Rancher that was deployed on top of Ubuntu 22.04.4, certification of other configuration is ongoing and compatibility is not guaranteed.
Notes
- When installing the ROCm kernel driver on your system ensure that AMD lists it as compatible with the ROCm release of the image (10.1 at time of writing, 7.2.1 for the Python backends).
- AMD documentation indicates that this will ensure functionality however your mileage may vary depending on the GPU and distro you are using.
- If you encounter an
Error 413on attempting to upload an audio file or image for whisper or llava/bakllava on a k8s deployment, note that the ingress for your deployment may require the annotationnginx.ingress.kubernetes.io/proxy-body-size: "25m"to allow larger uploads. This may be included in future versions of the helm chart.
Intel acceleration (sycl)
Requirements
You need a machine with an Intel GPU and a kernel that drives it, which every current Linux kernel does. You do not need to install any Intel graphics packages: the backends carry their own copy of the Intel graphics driver, so they work on a machine that has none installed, and on a machine whose own driver was built against a newer C library than the backend.
If you build from source instead of using the images, you need the Intel oneAPI Base Toolkit.
Using your own Intel driver instead
The carried driver comes from Intel’s own package repository, so it knows the cards released up to the point the image was built. If your GPU is newer than that, or you would rather use the driver your distribution ships, point the backend at it:
Set the path to wherever your distribution keeps that file. Whatever you set is used as is, and the carried driver is left alone.
The backends carry only the driver Level Zero uses, which is how llama.cpp reaches an Intel GPU. They do not carry an OpenCL driver, so OpenCL inside a container continues to use whatever the image itself provides.
Container images
To use SYCL, use the images with gpu-intel in the tag, for example v5.1.1-gpu-intel, …
The image list is on quay.
Example
To run LocalAI with Docker and sycl starting phi-2, you can use the following command as an example:
Notes
In addition to the commands to run LocalAI normally, you need to specify --device /dev/dri to docker, for example:
Note also that sycl does have a known issue to hang with mmap: true. You have to disable it in the model configuration if explicitly enabled.
On an integrated Intel GPU, the amount of free graphics memory can only be read if the driver is asked to report it. The backends do that for you by setting ZES_ENABLE_SYSMAN=1. If you set that variable yourself, your value is kept, and setting it to 0 makes the backend read zero free memory, because an integrated GPU has no memory of its own and shares the system’s.
Vulkan acceleration
Requirements
If using nvidia, follow the steps in the CUDA section to configure your docker runtime to allow access to the GPU.
Container images
To use Vulkan, use the images with the vulkan tag, for example v5.1.1-gpu-vulkan.
Example
To run LocalAI with Docker and Vulkan, you can use the following command as an example:
Notes
In addition to the commands to run LocalAI normally, you need to specify additional flags to pass the GPU hardware to the container.
These flags are the same as the sections above, depending on the hardware, for nvidia, AMD or Intel.
If you have mixed hardware, you can pass flags for multiple GPUs, for example:
NVIDIA L4T (Jetson/ARM64) acceleration
LocalAI supports NVIDIA ARM64 devices including Jetson Nano, Jetson Xavier NX, Jetson AGX Orin, and DGX Spark. Pre-built container images are available for both CUDA 12 and CUDA 13.
For detailed setup instructions, platform compatibility, and build commands, see the dedicated Running on Nvidia ARM64 page.
Quick start
GPU monitoring
Use these vendor-specific tools to verify that LocalAI is using your GPU and to monitor resource usage during inference.
NVIDIA
Look for non-zero GPU-Util and Memory-Usage values while running inference to confirm GPU acceleration is active.
AMD
LocalAI reads AMD GPU memory for /api/resources and the model fit check from rocm-smi. ROCm 7 and later images no longer ship rocm-smi; there LocalAI reads the same figures from the amdgpu driver in sysfs (/sys/class/drm/card*/device/mem_info_*). On APUs with a small VRAM carve-out and a large GTT pool (for example Strix Halo), the GTT pool counts toward GPU memory in both cases.
GET /api/resources also returns memory: how the GPU of the server reaches its memory (kind is unified, discrete or system for no GPU), the GPU it was read from (device), and the memory a model can use (total: the smallest discrete GPU, else the system memory). Such an APU counts as unified memory. The quick setup of the model editor uses it to pick its values; see Engine settings.
Intel
Troubleshooting
GPU not detected in container
- NVIDIA: Ensure
nvidia-container-toolkitis installed and the Docker runtime is configured. Test withdocker run --rm --gpus all nvidia/cuda:12.8.0-base-ubuntu24.04 nvidia-smi. - AMD: Ensure
/dev/driand/dev/kfdare passed to the container and thatamdgpu-dkmsis installed on the host. - Intel: Ensure
/dev/driis passed to the container. No Intel graphics packages are needed on the host, since the backends bring their own driver. If the GPU is a recent model that the carried driver does not know, point the backend at the host’s own driver as shown in Intel acceleration.
Model loads on CPU instead of GPU
- Check that
gpu_layersis set in your model YAML configuration. Setting it to a high number (e.g.,999) offloads all possible layers to GPU. - Verify you are using a GPU-enabled container image (tags containing
gpu-nvidia-cuda,gpu-hipblas,gpu-intel, etc.). - Enable
DEBUG=trueand check the logs for GPU initialization messages.
Out of memory (OOM) errors
- Reduce
gpu_layersto offload fewer layers, keeping some on CPU. - Lower
context_sizeto reduce VRAM usage. - Use VRAM Management to automatically unload idle models when running multiple models.
- Use quantized models (e.g., Q4_K_M) which require less memory than full-precision models.
ROCm: unsupported GPU target
The prebuilt hipblas images and backends support only the targets listed in Limitations. The container cannot rebuild them for another target: LocalAI has no REBUILD or GPU_TARGETS setting. To use another target, build the backend from source with AMDGPU_TARGETS set to your gfx target. See Build backends.
Intel SYCL: model hangs
SYCL has a known issue where models hang when mmap: true is set. Ensure mmap is disabled in the model configuration:
Slow performance or unexpected CPU fallback
f16: truein the model YAML sets 16-bit memory and KV cache for that model. It does not turn GPU use on. GPU use comes from the backend build andgpu_layers.- Set
threads: 1when using full GPU offloading to avoid CPU thread contention. - Verify the correct
BUILD_TYPEmatches your hardware (e.g.,cublasfor NVIDIA,hipblasfor AMD).