">
 

How I Got Ollama Running on My AMD Radeon RX 9060 XT Using WSL and ROCm

Iniciado por joomlamz, Hoje at 14:25

Respostas: 1   |   Visualizações: 1

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.

Saudações, comunidade do **webmastersmz.com**! Como especialista em tecnologia, analisei o tópico em inglês *"How I Got Ollama Running on My AMD Radeon RX 9060 XT Using WSL and ROCm"* e trago vos aqui os pontos técnicos mais importantes desta partilha.

Rodar modelos de Inteligência Artificial localmente tem-se tornado uma prioridade para muitos developers, mas o ecossistema CUDA da NVIDIA costuma dominar as atenções. O autor deste tópico partilha o passo-a-passo de como conseguiu contornar as limitações de hardware e colocar o Ollama a funcionar numa gráfica AMD Radeon (neste caso, a RX 9060 XT) utilizando o WSL (Windows Subsystem for Linux) em conjunto com a plataforma ROCm da AMD.

**Os pontos principais da análise técnica são:**
1. **WSL como ponte:** A utilização do WSL permite ter um ambiente Linux nativo dentro do Windows, o que facilita imenso a instalação de dependências e bibliotecas que, de outra forma, seriam complexas de configurar no Windows puro para hardware AMD.
2. **O papel do ROCm:** O ROCm (Radeon Open Compute) é a resposta da AMD ao CUDA. É a camada de software fundamental que permite à placa gráfica realizar computação paralela, acelerando drasticamente a inferência dos modelos de linguagem (LLMs) no Ollama.
3. **Desafios de Compatibilidade:** A configuração exige atenção redobrada às versões dos drivers, pacotes ROCm suportados e às variáveis de ambiente no Linux para que o Ollama reconheça corretamente a arquitetura da GPU AMD.

Esta é uma excelente alternativa económica para quem quer explorar IA generativa localmente sem investir obrigatoriamente numa placa NVIDIA. Queria abrir o debate aqui no **webmastersmz.com**: *Alguém por aqui já tentou usar ROCm no WSL? Quais foram os maiores gargalos de performance ou erros de compilação que encontraram? Deixem as vossas experiências nos comentários!*

---

Para garantir que os vossos projetos e fóruns rodam sem falhas, convido-vos a conhecer as soluções de alojamento de alta performance da AplicHost em https://aplichost.com.

How I Got Ollama Running on My AMD Radeon RX 9060 XT Using WSL and ROCm



Tópico: How I Got Ollama Running on My AMD Radeon RX 9060 XT Using WSL and ROCm
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------
I wanted to start experimenting with AI for a while.

At work, I didn't really have enough time to properly explore this new ecosystem and understand how these tools could be used. But I had another resource available: my personal hardware.

I'm a gamer, so I have a reasonably powerful desktop PC. I'm also a developer, with a laptop running Ubuntu and a NAS.

That made me wonder:

Can I use my gaming PC to run AI models locally?

The answer is yes.

This article is a small walkthrough of my experience setting up a local AI environment using an AMD Radeon GPU, Windows, WSL, ROCm, and Ollama.

My hardware is (yes, I'm Team Red):

• AMD Ryzen 7 5700X

• 32 GB RAM

• AMD Radeon RX 9060 XT with 16 GB VRAM

• Ubuntu 26.04 running under WSL



Installing WSL and Ubuntu


The first step is to make sure that WSL is installed and up to date.

The general process is:

• Check your current WSL version.

• Update WSL.

• Install Ubuntu.

• Create your user account.

• Update the Ubuntu installation.



WSL


From PowerShell:

# Check the current version of WSL
wsl -v

# Update WSL
wsl --update

# Install Ubuntu
wsl --install -d Ubuntu

# Start Ubuntu
wsl -d Ubuntu

# Stop Ubuntu
wsl --terminate Ubuntu

# Remove the Ubuntu distribution
wsl --unregister Ubuntu



Ubuntu


Once Ubuntu is installed, update the system and install zstd.

We will need it later to extract Ollama.

sudo apt update
sudo apt upgrade
sudo apt autoclean
sudo apt autoremove

sudo apt install zstd



Installing Ollama with ROCm support


Ollama is the foundation of this setup.

It allows us to download and run AI models locally while providing different compute backends, including CPU, CUDA, and ROCm.



Installation


One thing that wasn't immediately obvious to me was that Ollama provides a specific ROCm backend.

The installation is split into two parts:

• Install Ollama.

• Install the ROCm backend.

# Install Ollama
curl -fsSL https://ollama.com/download/ollama-linux-amd64.tar.zst \
| sudo tar --zstd -x -C /usr

# Install the ROCm backend
curl -fsSL https://ollama.com/download/ollama-linux-amd64-rocm.tar.zst \
| sudo tar --zstd -x -C /usr

Then create the Ollama user and add your current user to the Ollama group:

# Create the Ollama user and group
sudo useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama

# Add the current user to the Ollama group
sudo usermod -a -G ollama $(whoami)

The official documentation I used:

https://docs.ollama.com/linux#manual-install

https://docs.ollama.com/linux#amd-gpu-install



Running Ollama as a service


I chose to run Ollama as a systemd service.

Create or edit the service configuration:

sudo nano /etc/systemd/system/ollama.service

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=$PATH"
# Required to detect the GPU through DXG
Environment="HSA_ENABLE_DXG_DETECTION=1"
# Optional: expose Ollama outside of WSL
Environment="OLLAMA_HOST=0.0.0.0:11434"

[Install]
WantedBy=default.target

Then reload systemd and start the service:

sudo systemctl daemon-reload
sudo systemctl enable ollama
sudo systemctl start ollama.service

sudo systemctl status ollama.service

More information about running Ollama as a service:

https://docs.ollama.com/linux#adding-ollama-as-a-startup-service-recommended



Installing DXG support


The GPU needs to be exposed to the WSL environment.

For my setup, I used librocdxg.

One important detail: version 1.2.2 solved an issue I encountered with version 1.2.0.

So, if you're having issues with GPU detection, the version may matter.

wget https://github.com/ROCm/librocdxg/releases/download/v1.2.2/rocdxg-roct_1.2.2_amd64.deb

sudo apt install ./rocdxg-roct_1.2.2_amd64.deb

More information about the project:

https://github.com/ROCm/librocdxg



Checking that Ollama is using the GPU


At this point, everything should be configured.

Restart Ollama:

sudo systemctl restart ollama.service

Then check the Ollama logs:

sudo journalctl -u ollama --no-pager -o cat | grep "inference compute"

You should see something similar to:

library=ROCm compute=gfxXXXX description="[NAME_OF_YOUR_GPU]"

The important part is:

library=ROCm

You don't want Ollama to silently fall back to CPU inference.

In my case, I get:

time=2026-08-28T12:38:20.900+02:00 level=INFO source=types.go:32 msg="inference compute" id=0 filter_id=0 library=ROCm compute=gfx1200 name=ROCm0 description="AMD Radeon RX 9060 XT" libdirs=ollama,rocm_v7_2 driver=0.0 pci_id=0000:2b:00.0 type=discrete total="15.9 GiB" available="14.2 GiB"

As you can see, Ollama detects:

• The ROCm backend.


gfx1200.

• The AMD Radeon RX 9060 XT.

• Approximately 16 GB of VRAM.

AMD provides a compatibility matrix to identify which gfx version corresponds to your GPU:

https://rocm.docs.amd.com/en/latest/compatibility/compatibility-matrix.html?fam=radeon&gpu=amd-radeon-rx-9070-gre&gfx=gfx1201&os=ubuntu

I also found references suggesting that it may be possible to enable support for some older gfx versions, but I didn't need to do this for my setup.



Running a model


Time for the interesting part.

Download and run a model:

ollama run qwen3:8b

Ask the model something and let it generate a response.

You can exit the interactive session with:

/bye

You can then check where the model is running:

ollama ps

The output should indicate that the model is running on the GPU.

NAME        ID              SIZE      PROCESSOR
qwen3:8b    xxxxxxxxxxxx    5.2 GB    100% GPU

You can also open the Windows Task Manager and monitor your GPU usage.

Once the model starts running, you should see:

• VRAM usage increasing.

• GPU compute activity increasing.

• The model using the GPU instead of relying entirely on the CPU.



Bonus




Exposing Ollama to your local network


By default, your Ollama instance is running inside WSL.

If you want to access it from other machines on your local network, you need to expose the port through Windows.

On the Windows host, open PowerShell as Administrator.

First, create a firewall rule:

New-NetFirewallRule `
-DisplayName "Ollama WSL LAN" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 11434 `
-Action Allow `
-RemoteAddress [IP_BASE_TO_LISTEN]/24

Then forward the port between Windows and WSL:

netsh interface portproxy add v4tov4 `
listenaddress=[IP_HOST_WSL] `
listenport=11434 `
connectaddress=[IP_UBUNTU_IMAGE] `
connectport=11434

From another computer on your local network, you can test the Ollama API with:

curl.exe http://[IP_OF_OLLAMA_HOST]:11434/api/tags

If everything is configured correctly, Ollama should respond with the list of installed models.



Keeping WSL alive after closing the terminal


By default, WSL may stop after some time when no active terminal is connected.

To keep the WSL environment alive, create a .wslconfig file in your Windows user profile directory.

Add:

[general]
instanceIdleTimeout=-1

After modifying the configuration, restart the WSL distribution so the configuration is taken into account

Now once you started the image you will need to kill it manually.

wsl --terminate Ubuntu



Ollama is no longer accessible after restarting the PC


I encountered one additional issue.

After restarting my PC, I could start the WSL distribution, but Ollama was no longer accessible from the local network.

In my case, restarting the Windows iphlpsvc service solved the problem.

Open PowerShell as Administrator:

Restart-Service iphlpsvc -Force

After that, Ollama became accessible again.



Conclusion


This setup allowed me to turn my gaming PC into a local AI machine without replacing Windows or dedicating the entire computer to Linux.

The combination of:

• Windows

• WSL

• Ubuntu

• AMD Radeon

• ROCm

• Ollama

provides a relatively convenient environment for experimenting with local AI models.

The most important part of the setup, in my experience, was making sure that Ollama was actually using the ROCm backend and the GPU.

Once that was working, running a model such as qwen3:8b was straightforward.

Hopefully, this will save some time for other AMD GPU users who want to experiment with local AI on Windows.


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: