RTX 5060 Ti and RX 6600 installed together in one machine The RTX 5060 Ti (top) and the RX 6600 (bottom), sharing one machine.

Introduction

I was already running Qwen4-35B-A3B (Q4_K_M) on an RTX 5060 Ti with 16 GB. It fits: llama.cpp keeps part of the model’s experts in system RAM. I also had an RX 6600 (8 GB) lying around, so I wanted to see whether adding it, for 24 GB of VRAM in total, would buy me a bigger context window.

Most multi-GPU guides assume two matching NVIDIA cards. This one doesn’t: one card is NVIDIA, the other is AMD, they use different drivers and different compute APIs, and llama.cpp still runs a single model across both of them, in a single process, inside a single Docker container.

In this post I’ll walk through:

  • why layer split is the split mode that makes mixed vendors work
  • building llama.cpp with CUDA and Vulkan backends in one image
  • passing both GPUs into Docker
  • running Qwen4-35B-A3B (Unsloth’s UD-Q4_K_M quant) at 256K context
  • benchmarks: both GPUs vs the RTX alone, from 256K up to 1M context
  • the pitfalls that cost me hours
  • pointing Claude Code and Pi at the local model

Everything is in Docker Compose, so it’s reproducible once the host drivers are in place.

Note

If the drivers are already set up (the NVIDIA driver and Container Toolkit working with Docker, and the AMD card showing up in vulkaninfo), you can skip ahead to Building llama.cpp with CUDA + Vulkan.


The idea: two backends, one process

llama.cpp can load more than one compute backend into the same process. So:

  • the NVIDIA card runs on the CUDA backend (the fastest option for NVIDIA)
  • the AMD card runs on the Vulkan backend (through Mesa’s RADV driver)

With layer split, each GPU holds a contiguous block of the model’s layers. When a token is processed, only the small hidden state crosses from one card to the other, so the two backends never need to talk to each other directly.

llama.cpp has three split modes, and only one of them is a good fit here:

Split modeWorks across CUDA + Vulkan?Notes
layer (default)YesPipelined; each GPU owns whole layers
rowNoCUDA only
tensorTechnically, but not worth itExperimental; syncs partial results through system RAM on every layer

Why Vulkan and not ROCm for the AMD card?

The RX 6600 (Navi 23, gfx1032) isn’t an officially supported ROCm GPU; you’d need HSA_OVERRIDE_GFX_VERSION=10.3.0 and a HIP build next to the CUDA one. Vulkan needs nothing but Mesa, works in a container with just /dev/dri passed in, and keeps the build simple.

Set your expectations

The cards aren’t equally fast: the RX 6600 has roughly half the memory bandwidth of the RTX. So don’t expect the pair to be faster than the RTX on its own. The point of adding the second card is extra VRAM (24 GB total), not double the tokens per second. Whether that extra VRAM was worth it turned out to be more interesting than I expected; see the benchmarks.


The setup

GPU 0NVIDIA GeForce RTX 5060 Ti, 16 GB (Blackwell, sm_120)
GPU 1AMD Radeon RX 6600, 8 GB (Navi 23, gfx1032)
CPUIntel Xeon E5-2680 v4 (18 vCPUs given to the VM, AVX2)
RAM62 GiB, no swap
OSUbuntu 24.04, kernel 6.8, a VM with both GPUs passed through
NVIDIA driver580 (open kernel modules)
Docker29.4, Compose v5.1, NVIDIA Container Toolkit 1.19
llama.cppbuild 12991 (commit 7a7142b20)

Yes, this is an old Xeon in my homelab. That matters later, because part of the model ends up running on the CPU.


Host setup: drivers

The container brings its own CUDA runtime and Vulkan loader, but the kernel drivers have to be on the host.

NVIDIA

Install the driver from Ubuntu’s repos. The NVIDIA Container Toolkit isn’t in them: add NVIDIA’s apt repository first, following the Container Toolkit install guide. Then install both and register the runtime with Docker:

sudo apt install nvidia-driver-580-open nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
nvidia-smi

AMD: use the kernel’s built-in driver

The amdgpu driver ships with the Ubuntu kernel, in linux-modules-extra, with its firmware in linux-firmware. Use the linux-generic meta-package so every future kernel brings both:

sudo apt install linux-generic linux-modules-extra-$(uname -r)
sudo modprobe amdgpu        # or reboot
sudo usermod -aG render,video $USER

Check it:

lsmod | grep amdgpu
ls /dev/dri/                                  # a new card* and renderD* node
vulkaninfo --summary | grep deviceName        # should list the RX 6600 (RADV)

Pitfall: no driver on a VM kernel

Card detected, but no driver. dmesg showed amdgpu: Unknown symbol drm_dp_mst_.... My VM used the linux-virtual kernel meta-package (common on VMs and cloud images), which doesn’t install linux-modules-extra, so amdgpu and the display helpers it needs were missing. Fix: install linux-modules-extra-$(uname -r) and switch to linux-generic.


Building llama.cpp with CUDA + Vulkan in one image

llama.cpp ships separate cuda.Dockerfile and vulkan.Dockerfile files in .devops/. I merged them into one. The build context is a llama.cpp checkout next to my project folder, so the upstream repo stays untouched:

projects/
├── llama.cpp/          # git clone https://github.com/ggml-org/llama.cpp
└── llama-docker/
    ├── Dockerfile
    ├── docker-compose.yaml
    └── .env

The Dockerfile has three stages: the web UI (Node), the build (CUDA devel image plus Vulkan headers), and a slim runtime image.

ARG UBUNTU_VERSION=24.04
ARG CUDA_VERSION=12.8.1
ARG GCC_VERSION=14
ARG NODE_VERSION=24

# 1. llama-server's browser UI
FROM docker.io/node:${NODE_VERSION} AS web
ARG APP_VERSION=N/A
WORKDIR /app/ui/apps/chat
COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./
RUN npm ci
COPY ui/apps/chat/ ./
COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json
COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/
COPY ui/lib/voice/src/ /app/ui/lib/voice/src/
COPY ui/lib/harness/src/ /app/ui/lib/harness/src/
COPY ui/lib/huggingface/src/ /app/ui/lib/huggingface/src/
RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build

# 2. Build with both backends
FROM docker.io/nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION} AS build
ARG GCC_VERSION
# 120 = RTX 50-series (Blackwell). Building one arch keeps compile time down.
ARG CUDA_DOCKER_ARCH=120

RUN apt-get update && \
    apt-get install -y gcc-${GCC_VERSION} g++-${GCC_VERSION} build-essential cmake git libssl-dev libgomp1 \
        libvulkan-dev glslc spirv-headers

ENV CC=gcc-${GCC_VERSION} CXX=g++-${GCC_VERSION} CUDAHOSTCXX=g++-${GCC_VERSION}

WORKDIR /app
COPY . .
COPY --from=web /app/ui/apps/chat/dist ui/apps/chat/dist

RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DGGML_VULKAN=ON \
        -DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH} \
        -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_BUILD_TESTS=OFF \
        -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
    cmake --build build --config Release -j$(nproc) --target llama-server llama-bench llama-cli

RUN mkdir -p /app/lib && find build -name "*.so*" -exec cp -P {} /app/lib \;

# 3. Runtime
FROM docker.io/nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION} AS server

# libvulkan1 + mesa-vulkan-drivers provide RADV for the AMD card.
RUN apt-get update \
    && apt-get install -y libgomp1 curl libvulkan1 mesa-vulkan-drivers \
    && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib64:/usr/local/nvidia/lib:${LD_LIBRARY_PATH}
ENV LLAMA_ARG_HOST=0.0.0.0
ENV LLAMA_ARG_PORT=8080

COPY --from=build /app/lib/ /app
COPY --from=build /app/build/bin/llama-server /app/build/bin/llama-bench /app/build/bin/llama-cli /app/

WORKDIR /app
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
ENTRYPOINT [ "/app/llama-server" ]

The important lines are the CMake flags:

FlagWhy
-DGGML_CUDA=ON -DGGML_VULKAN=ONBoth backends in one build
-DCMAKE_CUDA_ARCHITECTURES=120Only compile kernels for the RTX 50-series. Set this to your card’s arch
-DGGML_BACKEND_DL=ONBackends are built as loadable libraries, picked up at runtime
-DGGML_CPU_ALL_VARIANTS=ONCPU backend for every instruction set; the best one for the host is chosen at runtime

Ubuntu 24.04’s stock Vulkan headers are new enough, so no extra SDK is needed. The resulting image is about 6.2 GB. Rebuild it after every git pull in llama.cpp.


Passing both GPUs into the container

Each card gets in through a different mechanism:

CardHowIn docker-compose.yaml
NVIDIANVIDIA Container Toolkitdeploy.resources.reservations.devices with driver: nvidia
AMDPlain device nodesdevices: [/dev/dri:/dev/dri] + group_add for render and video

Here’s the full compose file:

services:
  llama:
    image: local/llama.cpp:server-cuda-vulkan
    build:
      context: ../llama.cpp
      dockerfile: ../llama-docker/Dockerfile
      args:
        CUDA_DOCKER_ARCH: "120"
    container_name: llama-qwen4
    restart: unless-stopped
    ports:
      - "${PORT:-8080}:8080"
    volumes:
      # Same path as on the host, so MODEL in .env works in both places.
      - /mnt/models:/mnt/models:ro
    environment:
      # CUDA only for the NVIDIA card. Leaving out "graphics" keeps NVIDIA's Vulkan
      # driver out of the container, so the only Vulkan GPU is the AMD card.
      NVIDIA_DRIVER_CAPABILITIES: compute,utility
    devices:
      - /dev/dri:/dev/dri          # AMD card for Mesa RADV
    group_add:
      - "992"                      # render (numeric GID from the host)
      - "44"                       # video
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    command:
      - --model
      - ${MODEL}
      - --alias
      - qwen4-35b-a3b
      - --device
      - ${DEVICES:-CUDA0,Vulkan0}
      - --split-mode
      - layer
      # No --n-gpu-layers here: --fit only works when it's left unset.
      - --flash-attn
      - "on"
      - --cache-type-k
      - q8_0
      - --cache-type-v
      - q8_0
      - --ctx-size
      - ${CTX:-262144}
      - --fit
      - "on"
      - --jinja

Three details that matter:

  • NVIDIA_DRIVER_CAPABILITIES: compute,utility. Without graphics, NVIDIA’s own Vulkan driver stays out of the container. Otherwise the RTX shows up twice, as CUDA0 and as a Vulkan device, and the device numbering gets confusing.
  • Pass all of /dev/dri, not a single renderD node. On my machine the render-node numbers swapped between boots (renderD129 one day, renderD128 the next). Mesa picks the AMD card out of the folder by itself.
  • group_add takes numeric GIDs from the host. Get yours with getent group render video. Without them the container can’t open the render node.

Build the image with docker compose build, then check what the container sees:

llama-server list-devices output showing CUDA0 (RTX 5060 Ti) and Vulkan0 (RX 6600) --list-devices inside the container. Free memory is low here because the server was already running on both cards.

One CUDA device, one Vulkan device. That’s exactly what we want.


The model: Qwen4-35B-A3B (UD-Q4_K_M)

I used unsloth/Qwen4-35B-A3B-GGUF, the UD-Q4_K_M folder: two shards, 32.8 GiB in total. llama.cpp supports it (architecture qwen4exp) since commit 74e7f4465, so you need a recent build.

A 32.8 GiB file runs on a 16 GB card, or on 16 + 8 GB, because much of the file never needs to be in VRAM:

PartSize (estimated)Where it lives
n-gram embedding tables~11.5 GiBRead row by row from the memory-mapped file; never in VRAM
MoE experts (40 layers × 256 experts)~19.5 GiB (~0.49 GiB per layer)GPU, or system RAM per layer
Attention, recurrent layers, embeddings, rest~1.8 GiBGPU

It’s a mixture-of-experts model with only ~3B parameters active per token. That makes it cheap to keep some layers’ experts in system RAM: each such layer costs the CPU roughly 16 MB of reads per token, and frees about 0.5 GiB of VRAM for context.

Why 256K context fits

Qwen4-35B-A3B is a hybrid: 30 of its 40 layers are recurrent (gated delta-net) with a small fixed state, and only 10 are full-attention layers with a KV cache. So the KV cache is tiny for a model this size: about 20 KiB per token at f16, 10.6 KiB at q8_0.

ContextKV f16KV q8_0
128K2.5 GiB1.3 GiB
256K5 GiB2.7 GiB
512K10 GiB5.3 GiB
1M (model max)20 GiB10.6 GiB

Even the full 1M context fits with a q8_0 cache, if enough expert layers move to the CPU, and it does run (slowly, see the benchmarks). Note what that means: for this model, context length is limited by how many experts you’re willing to push to the CPU, not by VRAM alone. The RTX by itself already runs 256K. I use 256K as the default.

Download

The UD-Q4_K_M quant comes as two GGUF files (shards) in the UD-Q4_K_M folder of unsloth/Qwen4-35B-A3B-GGUF. Download both into one folder. I keep all my models on a separate disk mounted at /mnt/models, one folder per model:

/mnt/models/Qwen/Qwen4-35B-A3B-UD-Q4_K_M/
├── Qwen4-35B-A3B-UD-Q4_K_M-00001-of-00002.gguf   # 22.0 GiB
└── Qwen4-35B-A3B-UD-Q4_K_M-00002-of-00002.gguf   # 10.7 GiB

Check both files against the SHA-256 hashes Hugging Face shows on each file’s page:

sha256sum /mnt/models/Qwen/Qwen4-35B-A3B-UD-Q4_K_M/*.gguf

The .env file

docker-compose.yaml reads its settings from a .env file in the same folder (llama-docker/.env). Mine:

# /mnt/models is mounted at the same path inside the container.
# Point it at shard 1; llama.cpp loads shard 2 on its own.
MODEL=/mnt/models/Qwen/Qwen4-35B-A3B-UD-Q4_K_M/Qwen4-35B-A3B-UD-Q4_K_M-00001-of-00002.gguf

# 262144 = 256K (recommended start). 524288 = 512K, 1048576 = 1M (the model's max).
CTX=262144

PORT=8080
VariableWhat it does
MODELPath to the model, as seen inside the container. Always point it at the first shard (-00001-of-00002); llama.cpp finds the second one in the same folder by its name
CTXContext size in tokens, passed to --ctx-size
PORTPort on the host; inside the container the server always listens on 8080
DEVICESOptional, not in my .env. Defaults to CUDA0,Vulkan0; set DEVICES=CUDA0 to run on the RTX alone

The path works unchanged in both places because compose mounts the models disk read-only at the same path inside the container (/mnt/models:/mnt/models:ro). If your models live somewhere else, change that volume line and MODEL together. Keep both shards in the same folder and don’t rename them.

If you use the Hugging Face cache instead, mount the whole cache folder rather than one snapshot folder: the files there are symlinks into blobs/, and those have to resolve inside the container.


Running it

docker compose up -d && docker compose logs -f

The server listens on port 8080 with an OpenAI-compatible API under /v1, an Anthropic-compatible /v1/messages, and the browser UI at /.

What each flag does:

FlagWhy
--device CUDA0,Vulkan0The RTX through CUDA, the AMD card through Vulkan
--split-mode layerThe only split that works across the two backends
--flash-attn onRequired for a quantized KV cache
--cache-type-k/v q8_0Halves the KV cache, close to lossless
--ctx-size 262144256K context
--fit onllama.cpp picks the per-GPU layer split and how many expert layers go to the CPU, so weights + KV cache fit
--jinjaUse the model’s own chat template
--alias qwen4-35b-a3bA readable model name for clients instead of the file path

--fit on is the star here. Instead of tuning --tensor-split and --n-cpu-moe by hand, llama.cpp measures free memory on each device and fills both cards, leaving about 1 GB of headroom on each. If you’d rather tune by hand, something like --n-cpu-moe 8 --tensor-split 15,8 is a reasonable start for this pair.

Startup takes about 23 seconds with the model in the page cache.

A few rules for this model:

  • Don’t add --no-mmap. The n-gram tables are read straight from the memory-mapped file.
  • Don’t combine --fit on with --n-gpu-layers. More on this below.
  • Watch RAM at big contexts if, like me, you have no swap.

Benchmarks

All tests go through llama-server’s chat API and generate 256 tokens; prompts are a short question (chat), 16K tokens and 64K tokens of code. Mean of 2 runs.

256K context: both GPUs vs the RTX alone
Through llama-server's chat API, mean of 2 runs.
  • Generation: the RTX alone is about 2x faster (34.5 vs 17.3 t/s).
  • Prompt processing: both GPUs are 18–28% faster, so long prompts reach the first token sooner.
Both GPUs as the context window grows
Same model, same prompts; only --ctx-size changes.
  • 512K: generation barely changes (16.0 → 15.5 t/s), but prompts get about 35% slower (a 64K prompt waits 284 s instead of 194 s).
  • 1M works, but generation drops to 5.6–10 t/s.

The pitfalls that cost me hours

1. --n-gpu-layers silently turns off --fit

My first compose file had --n-gpu-layers 99 and --fit on. --fit gives up when the user has set GPU layers:

failed to fit params to free device memory: n_gpu_layers already set by user to 99, abort

Every expert then stays on the GPUs, the KV cache no longer fits, cudaMalloc failed: out of memory, and the container restarts in a loop. Remove --n-gpu-layers and let --fit do its job.

2. AMD runtime power management made it ~6x slower

This one was nasty. After a few seconds idle, amdgpu powers the card down (runtime PM, “BACO” in dmesg). Before powering down it moves everything in VRAM out to system RAM, and on wake-up it leaves it there. llama.cpp keeps running, but the RX 6600 now reads its layers over PCIe: prompt processing dropped from ~370 t/s to ~60 t/s while the RTX sat at 0%.

The symptom: the AMD card is busy, but its VRAM is nearly empty and GTT (system memory mapped for the GPU) holds its share:

cat /sys/class/drm/card*/device/mem_info_vram_used   # AMD: ~25 MiB instead of ~7 GB
cat /sys/class/drm/card*/device/mem_info_gtt_used    # AMD: ~7.7 GB
sudo dmesg | grep -E 'PSP is resuming|SMU is resum'  # wake-ups line up with the slowdown

The fix is a udev rule that keeps AMD GPUs powered, then a restart so llama-server loads its buffers back into VRAM:

echo 'ACTION=="add|bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x1002", ATTR{class}=="0x030000", ATTR{power/control}="on"' \
  | sudo tee /etc/udev/rules.d/80-amdgpu-no-runtime-pm.rules

# apply now without a reboot (find your PCI address with: lspci | grep VGA)
echo on | sudo tee /sys/bus/pci/devices/0000:02:00.0/power/control
docker compose restart

Using it from Claude Code

llama-server implements Anthropic’s Messages API (/v1/messages), so Claude Code can talk to it directly. One catch: ANTHROPIC_BASE_URL applies to the whole session, so the local model can’t sit in the same /model list as Claude models. Instead I gave it its own settings profile, so plain claude stays unchanged.

~/.claude/qwen-local.json:

{
  "model": "qwen4-35b-a3b",
  "env": {
    "ANTHROPIC_BASE_URL": "http://localhost:8080",
    "ANTHROPIC_AUTH_TOKEN": "local-llama-server",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen4-35b-a3b",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "262144",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "ENABLE_TOOL_SEARCH": "false"
  }
}
alias claude-qwen='claude --settings ~/.claude/qwen-local.json'
SettingWhy
ANTHROPIC_AUTH_TOKENAny value works (the server has no key), and it means your claude.ai login is never sent to the local server
ANTHROPIC_DEFAULT_HAIKU_MODELBackground tasks use the “haiku” slot; point it at the local model too
CLAUDE_CODE_MAX_CONTEXT_TOKENSTell Claude Code the real 256K context
ENABLE_TOOL_SEARCH=falseRequired for this model, see below

Why tool search has to be off: by default Claude Code loads some tool definitions on demand, and the result names the tool in a tool_reference content part. The Qwen4 chat template only accepts text, image, video and audio parts, so every such request fails with HTTP 500:

Jinja Exception: Unexpected content part type tool_reference. Supported types are text, image, ...

With tool search off, all tool definitions go in upfront. The cost is a bigger first prompt (about 20K tokens), so the first “hi” takes close to a minute. In my tests a Read tool call completed correctly in 2 turns. Anthropic doesn’t officially support Claude Code with non-Claude models, so expect some rough edges.

Using it from Pi

Pi’s built-in llama.cpp provider only works with llama-server’s router mode. For a single-model server, add it as a plain OpenAI-compatible provider in ~/.pi/agent/models.json:

{
  "providers": {
    "llama-docker": {
      "name": "llama.cpp (Docker, dual GPU)",
      "baseUrl": "http://localhost:8080/v1",
      "api": "openai-completions",
      "apiKey": "local",
      "compat": { "thinkingFormat": "qwen-chat-template", "maxTokensField": "max_tokens" },
      "models": [
        {
          "id": "qwen4-35b-a3b",
          "name": "Qwen4 35B-A3B (local)",
          "reasoning": true,
          "input": ["text"],
          "contextWindow": 262144,
          "maxTokens": 32768,
          "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
        }
      ]
    }
  }
}

Then pi --model llama-docker/qwen4-35b-a3b. Pi’s system prompt is much smaller than Claude Code’s, so a plain reply came back in about 9 seconds and a tool call in about 8.


Conclusion

If one RTX gives more tokens per second, why add another GPU?

That’s the obvious question after the benchmarks. Qwen4-35B-A3B is a mixture-of-experts model. It holds 35B parameters, but uses only about 3B of them for each token.

  • On the RTX alone, the parts that don’t fit in VRAM sit in system RAM. Each token touches only a small slice of them, so the CPU barely slows things down.
  • Splitting across two cards means every token goes RTX → PCIe → RX 6600 → back. The RX 6600 is the slower card, and every token pays for that hop. That’s most likely why generation drops from 34.5 to 17.3 t/s.

So what does the two-GPU setup actually buy you?

BenefitDid it deliver?
Faster prompt processingYes, 18–28% faster on big prompts
More context (512K and up)Maybe. Both GPUs run 512K with almost the same generation speed as 256K, but I haven’t tested the RTX alone at 512K yet
Models too big for one cardYes, in principle. Not tested in this post, but this is where a second card really pays off: weights that don’t fit in 16 GB get 24 GB of VRAM to spread over

For this model, I’d run the RTX alone for chat and agent loops that generate a lot, and the dual setup when I mostly feed it long prompts. For a model that doesn’t fit on one card, a spare GPU from another vendor is a perfectly workable way to add VRAM.

What it takes

Mixing GPU vendors sounds like it should be a mess, but with llama.cpp it comes down to a handful of decisions:

  • CUDA for NVIDIA, Vulkan for AMD, both built into one binary
  • --split-mode layer, the only split that works across backends
  • --fit on without --n-gpu-layers, so llama.cpp places layers and experts for you

Either way, the result is a 35B model with a 256K context behind an OpenAI- and Anthropic-compatible API that coding agents can use with no API bill.