Fine-tuning LLMs on AMD GPUs with Unsloth Guide
Learn how to fine-tune large language models (LLMs) on AMD GPUs with Unsloth.
Fine-tune LLMs up to 2x faster with ~70% less memory on AMD hardware, no NVIDIA required. Unsloth supports AMD Radeon RDNA 3/3.5/4 (RX 6000–9000 series) on both Windows and Linux as well as data center GPUs including the MI300X (192GB).
One-line installer
To install Unsloth on AMD, the easiest way is to download our Desktop app.
Linux :
curl -fsSL https://unsloth.ai/install.sh | shWindows (PowerShell):
irm https://unsloth.ai/install.ps1 | iexThe manual steps below are for users who want to install the Unsloth Python library on AMD with the required dependencies.
Make a new isolated environment (Optional)
The steps below are for Linux. On Windows, use the Desktop app or the PowerShell installer above: they install AMD's Windows build of PyTorch for you.
To not break any system packages, make an isolated environment. Reminder to check what Python version you have! It might be python3, python3.12, python3.13 etc. Python 3.10 to 3.13 works.
apt update && apt install python3.13-venv -y
python3.13 -m venv unsloth_env
source unsloth_env/bin/activate
pip install uvInstall PyTorch
PyPI only has the NVIDIA (CUDA) build of PyTorch, so install the ROCm build first from the PyTorch index that matches your ROCm version. Check it with amd-smi version (the ROCm version: line), then:
uv pip install "torch<2.15" torchvision torchaudio \
--index-url https://download.pytorch.org/whl/rocm7.2 --upgrade --force-reinstallChange rocm7.2 to your ROCm version. Available index tags are rocm6.0 to rocm6.4 and rocm7.0 to rocm7.2. ROCm 6.5 to 6.9 uses rocm6.4, and ROCm 7.3 or newer uses rocm7.2. ROCm 6.0 or newer is required.
Or let this command pick the tag for you:
ROCM_VER="$(amd-smi version 2>/dev/null | sed -n 's/.*ROCm version: \([0-9]*\.[0-9]*\).*/\1/p' | head -n 1)"
[ -n "$ROCM_VER" ] || ROCM_VER="$(cut -d. -f1,2 /opt/rocm/.info/version 2>/dev/null)"
case "$ROCM_VER" in
6.[0-4]|7.[0-2]) ROCM_TAG="rocm$ROCM_VER" ;;
6.*) ROCM_TAG="rocm6.4" ;;
*) ROCM_TAG="rocm7.2" ;;
esac
echo "ROCm ${ROCM_VER:-unknown}: using $ROCM_TAG"
uv pip install "torch<2.15" torchvision torchaudio \
--index-url "https://download.pytorch.org/whl/$ROCM_TAG" --upgrade --force-reinstall
Install Unsloth
Unsloth on PyPI depends on torch, so a plain install can swap the ROCm PyTorch you just installed for the CUDA one from PyPI. To prevent that, pin your installed PyTorch and install with uv pip (not plain pip):
uv pip freeze | grep -E '^(torch|torchvision|torchaudio)==' > torch-pins.txt
echo "triton ; sys_platform == 'never'" >> torch-pins.txt
echo "xformers ; sys_platform == 'never'" >> torch-pins.txt
uv pip install "unsloth[amd]" --overrides torch-pins.txttorch-pins.txt should list a torch==...+rocm... line. The last two lines keep PyPI's triton from being installed over the Triton that came with your PyTorch, and skip PyPI's xformers, which is built for NVIDIA GPUs only.

Updating Unsloth
Upgrade only Unsloth, with the same pins:
uv pip install --upgrade-package unsloth --upgrade-package unsloth-zoo "unsloth[amd]" --overrides torch-pins.txtDo not run uv pip install -U unsloth or --force-reinstall without the pins: both resolve PyTorch again from PyPI and replace your ROCm build with the CUDA one. If that already happened, import unsloth reports an AMD GPU but no usable HIP accelerator: rerun the PyTorch step above, then this one.
Start fine-tuning with Unsloth!
And that's it. Try some examples in our Unsloth Notebooks page!
You can view our dedicated fine-tuning or reinforcement learning guides. Heres a brief example as well:
1. Set environment variables
export HF_HUB_DISABLE_XET=1 # Fixes HuggingFace download issues on AMD2. Load and configure model
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name = "unsloth/gemma-4-26b-a4b-it",
max_seq_length = 2048,
load_in_4bit = True,
)
model = FastModel.get_peft_model(
model,
r = 16,
lora_alpha = 16,
target_modules = ["q_proj", "k_proj", "v_proj", "o_proj"],
)3. Train
from trl import SFTTrainer, SFTConfig
trainer = SFTTrainer(
model = model,
tokenizer = tokenizer,
train_dataset = dataset,
formatting_func = formatting_func,
args = SFTConfig(
per_device_train_batch_size = 1,
gradient_accumulation_steps = 4,
max_steps = 60,
output_dir = "outputs",
report_to = "none",
),
)
trainer_stats = trainer.train()
Note: Flash Attention 2 is not installed on AMD GPUs by default, so Unsloth uses PyTorch's built-in SDPA attention instead. The warning can be safely ignored.
🔢 Reinforcement Learning on AMD GPUs
You can use our 📒gpt-oss RL auto win 2048 example on a MI300X (192GB) GPU. The goal is to play the 2048 game automatically and win it with RL. The LLM (gpt-oss 20b) auto devises a strategy to win the 2048 game, and we calculate a high reward for winning strategies, and low rewards for failing strategies.

The reward over time is increasing after around 300 steps or so!
The goal for RL is to maximize the average reward to win the 2048 game.

We used an AMD MI300X machine (192GB) to run the 2048 RL example with Unsloth, and it worked well!


You can also use our 📒automatic kernel gen RL notebook also with gpt-oss to auto create matrix multiplication kernels in Python. The notebook also devices multiple methods to counteract reward hacking.
The prompt we used to auto create these kernels was:
The RL process learns for example how to apply the Strassen algorithm for faster matrix multiplication inside of Python.

📚AMD Free One-click notebooks
AMD provides one-click notebooks equipped with free 192GB VRAM MI300X GPUs through their Dev Cloud. Train large models completely for free (no signup or credit card required):
GPT OSS MXFP4 (20B) - Inference
Gemma4 (E2B) - RL Sudoku
Unsloth Studio
You can use any Unsloth notebook by prepending https://amd-ai-academy.com/github/unslothai/notebooks/blob/main/nb in Unsloth Notebooks by changing the link from https://github.com/unslothai/notebooks/blob/main/nb/AMD-gpt_oss_(20B)_Reinforcement_Learning_2048_Game_BF16.ipynb to https://amd-ai-academy.com/github/unslothai/notebooks/blob/main/nb/AMD-Gemma4_(E2B)_Reinforcement_Learning_Sudoku_Game.ipynb


Last updated
Was this helpful?

