Project 002
verified working · may 2026
58 % / 42 % CPU / GPU · partial offload working

Ollama on RX 9070 XT — convincing it the GPU exists.

How to build Ollama from source with a ROCm/HIP backend targeting the AMD RX 9070 XT (gfx1201) on WSL2, so it stops pegging your CPU at 100 % and actually uses the card you bought.

Ollama (main) ROCm 7.2.1 gfx1201 WSL2 6.6.114 Ubuntu 24.04 Driver 32.0.31007.1017
§ 01

The problem

Out of the box, Ollama 0.23.1 falls back to CPU on the RX 9070 XT for two reasons:

// reasons it doesn't just work
  1. The prebuilt Ollama binary ships with no ROCm/HIP backend — only CUDA and CPU libraries.
  2. Even if it had ROCm, the RX 9070 XT (gfx1201) is new enough that many prebuilt ROCm binaries don't include it as a target.

Additionally, the WSL2 GPU path is different from bare-metal Linux. There is no /dev/kfd or /dev/dri in WSL2. Instead, the GPU is exposed via /dev/dxg (Microsoft's DirectX bridge), which ROCm must be told to use explicitly.

§ 02

Prerequisites

OS

WSL2 running Ubuntu (tested on 24.x)

Kernel 6.6.x-microsoft-standard-WSL2 or later.

DRV

Windows AMD driver 32.0.31007.1017 or later

Same standard Adrenalin driver used by the WSL2 + ROCm setup. No WSL2-specific variant needed.

ROCM

AMD ROCm installed at /opt/rocm

Tested with ROCm 7.2.1. Follow the WSL2 + ROCm survival guide first if you haven't installed it yet.

DISK

At least 20 GB free disk space

For the build artifacts. Bazel and CMake are not modest.

Verify ROCm sees your GPU

From WSL2 context, with the DXG detection envvar set:

bash · WSL2
HSA_ENABLE_DXG_DETECTION=1 HSA_OVERRIDE_GFX_VERSION=12.0.1 \
  /opt/rocm/bin/rocminfo | grep -A5 "Agent 2"

You should see AMD Radeon RX 9070 XT listed.

§ 03

Install build dependencies

Install Go (need 1.22+)

bash · WSL2
sudo snap install go --classic
go version

Install build tools & ROCm dev libraries

bash · WSL2
sudo apt install -y git build-essential gcc g++ \
    rocm-dev hipblas-dev rocblas-dev python3-dev

Verify CMake

bash · WSL2
cmake --version
# Need 3.21+
§ 04

Build Ollama with ROCm + gfx1201

Clone the repo

bash · WSL2
cd ~
git clone https://github.com/ollama/ollama
cd ollama

Configure CMake

Point CMake at your ROCm installation and set gfx1201 as the target:

bash · WSL2
cmake --preset "ROCm 6" \
  -DAMDGPU_TARGETS="gfx1201" \
  -DCMAKE_PREFIX_PATH="/opt/rocm-7.2.1;/opt/rocm"

You should see at the end:

cmake output
-- HIP and hipBLAS found
-- Configuring done
-- Build files have been written to: /home/<user>/ollama/build
INFO
The AMDGPU_TARGETS is deprecated warning is harmless — ignore it.

Compile (5–30 minutes depending on CPU)

bash · WSL2
cmake --build --preset "ROCm 6" -j$(nproc) 2>&1 | tee ~/ollama-build.log

A successful build ends with:

build log
[100%] Linking HIP shared module .../libggml-hip.so
[100%] Built target ggml-hip

Build the Go binary

bash · WSL2
go build -o ~/ollama/dist/ollama .
§ 05

Install the new binary & ROCm libraries

bash · WSL2
# Stop the running Ollama service
sudo systemctl stop ollama

# Back up the old binary (just in case)
sudo cp /usr/local/bin/ollama /usr/local/bin/ollama.backup

# Install the freshly built binary
sudo cp ~/ollama/dist/ollama /usr/local/bin/ollama

# Install the new ROCm/HIP backend libraries
sudo cp ~/ollama/build/lib/ollama/libggml-hip.so /usr/local/lib/ollama/
sudo cp ~/ollama/build/lib/ollama/libggml-base.so* /usr/local/lib/ollama/
§ 06

Configure systemd with ROCm envvars

The WSL2 GPU path requires specific environment variables. Create a systemd override:

bash · WSL2
sudo mkdir -p /etc/systemd/system/ollama.service.d/
sudo nano /etc/systemd/system/ollama.service.d/override.conf

Paste the following:

override.conf
[Service]
Environment="HSA_ENABLE_DXG_DETECTION=1"
Environment="HSA_OVERRIDE_GFX_VERSION=12.0.1"
Environment="HIP_VISIBLE_DEVICES=0"
Environment="HSA_ENABLE_SDMA=0"
Environment="ROCM_PATH=/opt/rocm"

Save with Ctrl+O, Enter, Ctrl+X.

VariablePurpose
HSA_ENABLE_DXG_DETECTION=1Tells ROCm to find the GPU via /dev/dxg (WSL2's DirectX bridge) instead of /dev/kfd.
HSA_OVERRIDE_GFX_VERSION=12.0.1Forces ROCm to treat the GPU as gfx1201 (required for RX 9070 XT).
HIP_VISIBLE_DEVICES=0Selects the first GPU.
HSA_ENABLE_SDMA=0Disables SDMA — can cause issues in WSL2.
ROCM_PATH=/opt/rocmPoints to your ROCm installation.
§ 07

Start & verify

bash · WSL2
sudo systemctl daemon-reload
sudo systemctl start ollama
sleep 3

# Check that the GPU is detected
sudo journalctl -u ollama --since "1 minute ago" | grep -iE "hip|gpu|rocm|gfx"

You should see a line like:

journalctl output
inference compute id=GPU-d838d7edd6273f86 library=ROCm compute=gfx1201
description="AMD Radeon RX 9070 XT" total="15.8 GiB" available="11.3 GiB"

Load a model and check the processor

bash · WSL2
ollama run qwen3.6:latest "hello"
ollama ps

Expected output:

ollama ps
NAME              ID              SIZE     PROCESSOR          CONTEXT
qwen3.6:latest    07d35212591f    26 GB    58%/42% CPU/GPU    4096
NOTE
The CPU/GPU split is normal — it means the model is larger than VRAM (16 GB), so Ollama offloads as many layers as it can to the GPU and runs the rest on CPU. Still dramatically faster than 100 % CPU.
§ 08

Rebuilding after an Ollama update

bash · ~/rebuild-ollama.sh
cat > ~/rebuild-ollama.sh << 'EOF'
#!/bin/bash
cd ~/ollama
git pull
cmake --preset "ROCm 6" \
  -DAMDGPU_TARGETS="gfx1201" \
  -DCMAKE_PREFIX_PATH="/opt/rocm-7.2.1;/opt/rocm"
cmake --build --preset "ROCm 6" -j$(nproc)
go build -o ~/ollama/dist/ollama .
sudo systemctl stop ollama
sudo cp ~/ollama/dist/ollama /usr/local/bin/ollama
sudo cp ~/ollama/build/lib/ollama/libggml-hip.so /usr/local/lib/ollama/
sudo cp ~/ollama/build/lib/ollama/libggml-base.so* /usr/local/lib/ollama/
sudo systemctl start ollama
EOF
chmod +x ~/rebuild-ollama.sh
§ 09

Troubleshooting

ERR · 01 ollama ps still shows 100% CPU after setup

Check which backend loaded:

bash
sudo journalctl -u ollama --since "5 minutes ago" | grep -i "load_backend"

If it shows libggml-cpu-alderlake.so, the HIP library isn't being picked up. Confirm libggml-hip.so exists in /usr/local/lib/ollama/.

ERR · 02 /dev/dri or /dev/kfd not found

Expected on WSL2. The GPU is accessed via /dev/dxg. Confirm it exists:

bash
ls -la /dev/dxg

If missing, run wsl --update from PowerShell (as Admin) and restart WSL2.

ERR · 03 CMake can't find HIP

Add -DCMAKE_PREFIX_PATH="/opt/rocm-7.2.1;/opt/rocm" to your cmake command, and verify the hip config exists:

bash
find /opt/rocm* -name "hip-config.cmake"
ERR · 04 rocm-smi shows "amdgpu not found"

Also expected in WSL2 — rocm-smi uses the native Linux KFD driver which isn't present. Use rocminfo with HSA_ENABLE_DXG_DETECTION=1 instead to verify GPU detection.

§ 10

Why this works

PixInsight and other apps that use ROCm on this same WSL2 setup work because they set HSA_ENABLE_DXG_DETECTION=1, which tells ROCm's HSA runtime to find the GPU through Microsoft's /dev/dxg DirectX bridge rather than the native Linux /dev/kfd path.

The prebuilt Ollama binary never sets this, and also ships without any ROCm backend compiled in — so building from source with the correct gfx1201 target and adding the environment variables is the complete fix.