Sign In

Train LoRAs on AMD GPU via WSL2 with ROCm 7.2 - [Setup guide - Feb26]

3

Train LoRAs on AMD GPU via WSL2 with ROCm 7.2 - [Setup guide - Feb26]

An Environment Setup Guide

- to Train ZIT/SDXL/IL/(maybe FLUX) LoRAs

- on AMD RDNA 4 GPUs (RX 9070/XT)

- via WSL2

- with ROCm 7.2

- using Ostris' ai-toolkit

Valid on: Feb 3, 2026

My setup: AMD RX 9070 (gfx1201), Windows 11

Disclaimer: I'm not an AI researcher nor a Linux wizard. I'm a normal user who wants to train on Windows with an AMD GPU because, much like you, I love pain. This guide is the result of trial-and-error, fighting with HSA Exceptions, memory leaks, and arguing with an AI.

If you know better, your corrections and suggestions are welcome! 😘


πŸ› οΈ Phase 1: Windows Prep

Get the latest AMD Drivers

Install WSL2

  • Official doc here

  • Make sure the functionality is enabled: press Windows key + R, type optionalfeatures, Enter. Look for "Windows Subsystem for Linux", check the box, OK, restart.

  • Open PowerShell

wsl --install Ubuntu-22.04
  • Create a username/password.

  • Press Win + R, type %UserProfile%, enter, create a text file named .wslconfig, paste this inside and save:

    [wsl2]
    memory=20GB  # If you have 32GB total, give WSL 20-24. If you have more than 32GB RAM, and you bought it before the shortage, I don't want to talk to you.
    swap=32GB    # For when memory runs out.


🐧 Phase 2: Ubuntu Prep

Copy/paste time!

  • In the PS terminal, start wsl

wsl
  • Update everything ritual

sudo apt update && sudo apt upgrade -y

All the necessary crap important stuff

  • Python

sudo apt install python3 python3-venv python3-pip -y
pip3 install --upgrade pip wheel
  • Kate because VI is scary and we like GUIs

sudo apt install kate -y
  • Node.js (for the fancy ai-toolkit interface that we won't be able to use fully 😒)
    Official doc here

sudo apt-get install curl -y
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash

# Close and re-open your terminal, then

wsl # Duh
nvm install --lts
wget https://repo.radeon.com/amdgpu-install/7.2/ubuntu/jammy/amdgpu-install_7.2.70200-1_all.deb
sudo apt install ./amdgpu-install_7.2.70200-1_all.deb
amdgpu-install -y --usecase=wsl,rocm,hip --no-dkms
# I don't know why I added hip

Sanity Check: Type rocminfo. If you see a wall of text with "gfx1201" somewhere, you're golden.


🐍 Phase 3: AI-Toolkit & PyTorch

AI-Toolkit

# Clone the repo
git clone https://github.com/ostris/ai-toolkit.git
cd ai-toolkit

# Create and activate the venv
python3 -m venv venv
source venv/bin/activate
  • Don't install requirements yet.

PyTorch

wget https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp310-cp310-linux_x86_64.whl
wget https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp310-cp310-linux_x86_64.whl
wget https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp310-cp310-linux_x86_64.whl
wget https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchaudio-2.9.0%2Brocm7.2.0.gite3c6ee2b-cp310-cp310-linux_x86_64.whl

pip3 uninstall torch torchvision triton torchaudio

pip3 install torch-2.9.1+rocm7.2.0.lw.git7e1940d4-cp310-cp310-linux_x86_64.whl torchvision-0.24.0+rocm7.2.0.gitb919bd0c-cp310-cp310-linux_x86_64.whl torchaudio-2.9.0+rocm7.2.0.gite3c6ee2b-cp310-cp310-linux_x86_64.whl triton-3.5.1+rocm7.2.0.gita272dfa8-cp310-cp310-linux_x86_64.whl
  • AMD suggest you then "update to WSL compatible runtime lib". I didn't need to but here goes

location=$(pip show torch | grep Location | awk -F ": " '{print $2}')
cd ${location}/torch/lib/
rm libhsa-runtime64.so*
  • Verify

python3 -c 'import torch' 2> /dev/null && echo 'Success' || echo 'Failure'
python3 -c 'import torch; print(torch.cuda.is_available())'
python3 -c "import torch; print(f'device name [0]:', torch.cuda.get_device_name(0))"
python3 -m torch.utils.collect_env

Requirements

pip3 install -r requirements.txt

βš™οΈ Phase 4: Compiling Bitsandbytes (╯‡░′)╯︡┻━┻

  • The pip-installed bitsandbytes just won't cut it. For the moment (0.49.2.dev) we have to compile it ourselves like Neanderthals.
    Official doc here

# Yeet the broken version
pip uninstall bitsandbytes -y

# Clone the repo
git clone https://github.com/bitsandbytes-foundation/bitsandbytes.git
cd bitsandbytes

# Install build tools & update CMake (important!)
sudo apt-get install -y build-essential cmake
pip install cmake --upgrade
hash -r

# Compile targeting our card (gfx1201, replace with your own arch if you aren't using a 9070/XT)
cmake -DCOMPUTE_BACKEND=hip -DBNB_ROCM_ARCH="gfx1201" -S .
make -j$(nproc)
pip install .

# Go back home
cd ..

πŸ–₯️ Phase 5: Actually Train Sh*t

Configure a job

  • First we need to build the GUI, cause we like GUIs, remember?

cd ui
npm run build_and_start
  • Go to the address it returns (should be http://localhost:8675)

  • The interface yells at you something like nvidia-smi is no good yada yada. We dgaf 😎

  • Use the UI to upload your dataset and tune your config; this guide does not go into details how to do that. Suggest you check Ostris' Youtube channel. Ostris is great and he smells good, we like Ostris.
    I'd still suggest to keep batch size and gradient accumulation both set to 1 - I'm having issues with any other value, even with free vram.

  • Once you're set, in "new job", click"advanced" and copy the YAML text.

  • In terminal: Ctrl+C, then

cd ..
kate
# Paste and save to ai-toolkit/config/my_job.yaml

Start the training

cd ~/ai-toolkit
python run.py config/my_job.yaml

Next time

  • Open the terminal, type

# Start WSL and activate the venv
wsl
cd ~/ai-toolkit
source venv/bin/activate

# Start the UI if you want, to create datasets / configs
cd ~/ai-toolkit/ui
npm run build_and_start

# save your config to YAML
kate
# Paste and save to ai-toolkit/config/my_job.yaml

# Run
cd ~/ai-toolkit
python run.py config/my_job.yaml

If this guide helped you in any way, I would love for you to leave a short comment!

If you don't want to that's OK, I wrote this on company time.

Take care and have fun ❀️

SGtW

secret_cyber_wolf_outpaint_150.png

3