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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- benchmark
|
| 4 |
+
- amd
|
| 5 |
+
- rocm
|
| 6 |
+
- gemma4
|
| 7 |
+
- local-llm
|
| 8 |
+
- linux
|
| 9 |
+
- spanish
|
| 10 |
+
- latam
|
| 11 |
+
language:
|
| 12 |
+
- es
|
| 13 |
+
- en
|
| 14 |
+
license: apache-2.0
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Gemma 4 on AMD RX 6700 XT + ROCm
|
| 18 |
+
|
| 19 |
+
> 🇲🇽 [Versión en Español](#versión-en-español) | 🇺🇸 [English Version](#english-version)
|
| 20 |
+
|
| 21 |
+
Benchmarks of Google's Gemma 4 (April 2026) running on AMD GPU with ROCm on Linux.
|
| 22 |
+
**This documentation doesn't exist in Spanish — for the LatAm community.**
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## English Version
|
| 27 |
+
|
| 28 |
+
### Why this matters
|
| 29 |
+
|
| 30 |
+
Most local AI guides assume:
|
| 31 |
+
- NVIDIA GPU (CUDA)
|
| 32 |
+
- Apple Silicon (macOS)
|
| 33 |
+
- $1,500+ USD budget
|
| 34 |
+
|
| 35 |
+
This repo documents that a **budget AMD GPU on Linux** running Gemma 4 — released April 2026 — outperforms a brand new Mac Mini M4 in decode speed, at a fraction of the cost.
|
| 36 |
+
|
| 37 |
+
### Hardware
|
| 38 |
+
|
| 39 |
+
| Component | Detail |
|
| 40 |
+
|-----------|--------|
|
| 41 |
+
| GPU | AMD RX 6700 XT 12GB (gfx1031) |
|
| 42 |
+
| CPU | AMD Ryzen 5 5600G |
|
| 43 |
+
| RAM | 16GB |
|
| 44 |
+
| OS | Pop!_OS 24.04 LTS |
|
| 45 |
+
| Ollama | 0.20.2 |
|
| 46 |
+
| ROCm override | HSA_OVERRIDE_GFX_VERSION=10.3.0 |
|
| 47 |
+
|
| 48 |
+
### Results (average of 3 runs)
|
| 49 |
+
|
| 50 |
+
| Model | Prefill (tok/s) | Decode (tok/s) | VRAM | Status |
|
| 51 |
+
|-------|----------------|----------------|------|--------|
|
| 52 |
+
| gemma4:e2b | 1022.39 | 85.00 | ~2GB | ROCm ✅ full GPU |
|
| 53 |
+
| gemma4:e4b | 697.91 | 57.34 | ~4GB | ROCm ✅ full GPU |
|
| 54 |
+
| gemma4:26b | 157.94 | 10.70 | 12GB + RAM offload | ROCm ⚠️ partial |
|
| 55 |
+
|
| 56 |
+
> **Note:** Prefill varies between runs due to KV cache warming.
|
| 57 |
+
> Decode is the number that matters for user experience — very consistent.
|
| 58 |
+
|
| 59 |
+
### Platform comparison (decode ~4B models)
|
| 60 |
+
|
| 61 |
+
| Hardware | Decode tok/s | Price (approx USD) |
|
| 62 |
+
|----------|--------------|--------------------|
|
| 63 |
+
| **RX 6700 XT + ROCm (this repo)** | **57-85** | existing hardware |
|
| 64 |
+
| Mac Mini M4 16GB | 25-40 | ~$600 new |
|
| 65 |
+
| RTX 3070 12GB | 50-80 | ~$500 used |
|
| 66 |
+
|
| 67 |
+
**The RX 6700 XT doubles the Mac Mini M4 16GB in decode speed for models that fit in VRAM.**
|
| 68 |
+
|
| 69 |
+
### The gfx1031 problem
|
| 70 |
+
|
| 71 |
+
The RX 6700 XT reports `gfx1031` architecture, but ROCm doesn't officially support it.
|
| 72 |
+
Without the override, Ollama falls back to CPU (~3-5 tok/s).
|
| 73 |
+
|
| 74 |
+
**Fix:**
|
| 75 |
+
```bash
|
| 76 |
+
sudo mkdir -p /etc/systemd/system/ollama.service.d
|
| 77 |
+
|
| 78 |
+
sudo tee /etc/systemd/system/ollama.service.d/rocm-fix.conf << 'CONF'
|
| 79 |
+
[Service]
|
| 80 |
+
Environment="HSA_OVERRIDE_GFX_VERSION=10.3.0"
|
| 81 |
+
Environment="ROCR_VISIBLE_DEVICES=0"
|
| 82 |
+
CONF
|
| 83 |
+
|
| 84 |
+
sudo systemctl daemon-reload
|
| 85 |
+
sudo systemctl restart ollama
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
**Verify it worked:**
|
| 89 |
+
```bash
|
| 90 |
+
journalctl -u ollama -n 10 --no-pager | grep "AMD Radeon"
|
| 91 |
+
# Expected output:
|
| 92 |
+
# description="AMD Radeon RX 6700 XT" total="12.0 GiB" available="11.1 GiB"
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
### Full setup
|
| 96 |
+
|
| 97 |
+
```bash
|
| 98 |
+
# 1. Install Ollama
|
| 99 |
+
curl -fsSL https://ollama.com/install.sh | sh
|
| 100 |
+
|
| 101 |
+
# 2. Apply ROCm fix (see above)
|
| 102 |
+
|
| 103 |
+
# 3. Pull models
|
| 104 |
+
ollama pull gemma4:e2b # 2B - fast, fits easily
|
| 105 |
+
ollama pull gemma4:e4b # 4B - great quality, fits in VRAM
|
| 106 |
+
ollama pull gemma4:26b # 26B - requires RAM offload on 12GB
|
| 107 |
+
|
| 108 |
+
# 4. Run
|
| 109 |
+
ollama run gemma4:e4b "Hello, what is MLOps?"
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
### Run the benchmark yourself
|
| 113 |
+
|
| 114 |
+
```bash
|
| 115 |
+
chmod +x bench_gemma4.sh
|
| 116 |
+
./bench_gemma4.sh
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
Runs 3 iterations per model, saves results to `gemma4_benchmark_results.md`.
|
| 120 |
+
|
| 121 |
+
---
|
| 122 |
+
|
| 123 |
+
## Versión en Español
|
| 124 |
+
|
| 125 |
+
### Por qué esto importa
|
| 126 |
+
|
| 127 |
+
La mayoría de guías de AI local asumen:
|
| 128 |
+
- GPU NVIDIA (CUDA)
|
| 129 |
+
- Apple Silicon (macOS)
|
| 130 |
+
- Presupuesto de $1,500 USD o más
|
| 131 |
+
|
| 132 |
+
Este repo documenta que una **GPU AMD de segunda mano en Linux** corriendo Gemma 4 (lanzada en abril 2026) supera en velocidad a un Mac Mini M4 nuevo, a una fracción del costo.
|
| 133 |
+
|
| 134 |
+
### Hardware
|
| 135 |
+
|
| 136 |
+
| Componente | Detalle |
|
| 137 |
+
|------------|---------|
|
| 138 |
+
| GPU | AMD RX 6700 XT 12GB (gfx1031) |
|
| 139 |
+
| CPU | AMD Ryzen 5 5600G |
|
| 140 |
+
| RAM | 16GB |
|
| 141 |
+
| OS | Pop!_OS 24.04 LTS |
|
| 142 |
+
| Ollama | 0.20.2 |
|
| 143 |
+
| Override ROCm | HSA_OVERRIDE_GFX_VERSION=10.3.0 |
|
| 144 |
+
|
| 145 |
+
### Resultados (promedio de 3 corridas)
|
| 146 |
+
|
| 147 |
+
| Modelo | Prefill (tok/s) | Decode (tok/s) | VRAM | Estado |
|
| 148 |
+
|--------|----------------|----------------|------|--------|
|
| 149 |
+
| gemma4:e2b | 1022.39 | 85.00 | ~2GB | ROCm ✅ GPU completa |
|
| 150 |
+
| gemma4:e4b | 697.91 | 57.34 | ~4GB | ROCm ✅ GPU completa |
|
| 151 |
+
| gemma4:26b | 157.94 | 10.70 | 12GB + offload a RAM | ROCm ⚠️ parcial |
|
| 152 |
+
|
| 153 |
+
> **Nota:** El prefill varía entre corridas por el KV cache warming.
|
| 154 |
+
> El decode es el número relevante para experiencia de usuario y es muy consistente.
|
| 155 |
+
|
| 156 |
+
### Comparativa vs otras plataformas (decode modelos ~4B)
|
| 157 |
+
|
| 158 |
+
| Hardware | Decode tok/s | Precio aprox MXN |
|
| 159 |
+
|----------|-------------|-----------------|
|
| 160 |
+
| **RX 6700 XT + ROCm (este repo)** | **57-85** | hardware existente |
|
| 161 |
+
| Mac Mini M4 16GB | 25-40 | ~$23,000 MXN nuevo |
|
| 162 |
+
| RTX 3070 12GB | 50-80 | ~$10,000 MXN usado |
|
| 163 |
+
|
| 164 |
+
**La RX 6700 XT dobla en velocidad al Mac Mini M4 16GB en modelos que caben en VRAM.**
|
| 165 |
+
|
| 166 |
+
### El problema del gfx1031
|
| 167 |
+
|
| 168 |
+
La RX 6700 XT reporta arquitectura `gfx1031` pero ROCm no la tiene en su lista de soporte oficial.
|
| 169 |
+
Sin el override, Ollama cae a CPU (~3-5 tok/s).
|
| 170 |
+
|
| 171 |
+
**Fix:**
|
| 172 |
+
```bash
|
| 173 |
+
sudo mkdir -p /etc/systemd/system/ollama.service.d
|
| 174 |
+
|
| 175 |
+
sudo tee /etc/systemd/system/ollama.service.d/rocm-fix.conf << 'CONF'
|
| 176 |
+
[Service]
|
| 177 |
+
Environment="HSA_OVERRIDE_GFX_VERSION=10.3.0"
|
| 178 |
+
Environment="ROCR_VISIBLE_DEVICES=0"
|
| 179 |
+
CONF
|
| 180 |
+
|
| 181 |
+
sudo systemctl daemon-reload
|
| 182 |
+
sudo systemctl restart ollama
|
| 183 |
+
```
|
| 184 |
+
|
| 185 |
+
**Verificar que funcionó:**
|
| 186 |
+
```bash
|
| 187 |
+
journalctl -u ollama -n 10 --no-pager | grep "AMD Radeon"
|
| 188 |
+
# Output esperado:
|
| 189 |
+
# description="AMD Radeon RX 6700 XT" total="12.0 GiB" available="11.1 GiB"
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
### Setup completo
|
| 193 |
+
|
| 194 |
+
```bash
|
| 195 |
+
# 1. Instalar Ollama
|
| 196 |
+
curl -fsSL https://ollama.com/install.sh | sh
|
| 197 |
+
|
| 198 |
+
# 2. Aplicar fix de ROCm (ver arriba)
|
| 199 |
+
|
| 200 |
+
# 3. Descargar modelos
|
| 201 |
+
ollama pull gemma4:e2b # 2B - rápido, cabe fácil
|
| 202 |
+
ollama pull gemma4:e4b # 4B - buena calidad, cabe en VRAM
|
| 203 |
+
ollama pull gemma4:26b # 26B - requiere offload a RAM en 12GB
|
| 204 |
+
|
| 205 |
+
# 4. Correr
|
| 206 |
+
ollama run gemma4:e4b "Hola, explica qué es MLOps"
|
| 207 |
+
```
|
| 208 |
+
|
| 209 |
+
### Correr el benchmark tú mismo
|
| 210 |
+
|
| 211 |
+
```bash
|
| 212 |
+
chmod +x bench_gemma4.sh
|
| 213 |
+
./bench_gemma4.sh
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
Corre 3 iteraciones por modelo y guarda los resultados en `gemma4_benchmark_results.md`.
|
| 217 |
+
|
| 218 |
+
### Modelos probados
|
| 219 |
+
|
| 220 |
+
| Modelo | Parámetros | Tipo | ¿Cabe en 12GB? |
|
| 221 |
+
|--------|-----------|------|----------------|
|
| 222 |
+
| gemma4:e2b | 2B | Dense | ✅ GPU completa |
|
| 223 |
+
| gemma4:e4b | 4B | Dense | ✅ GPU completa |
|
| 224 |
+
| gemma4:26b | 26B (4B activos, MoE) | MoE | ⚠️ offload parcial |
|
| 225 |
+
|
| 226 |
+
---
|
| 227 |
+
|
| 228 |
+
## About / Sobre este repo
|
| 229 |
+
|
| 230 |
+
Made in CDMX with second-hand hardware and free software.
|
| 231 |
+
Hecho en CDMX con hardware de segunda mano y software libre.
|
| 232 |
+
|
| 233 |
+
*[Positronica Labs](https://github.com/G10hdz) — Building AI tools for Latin America.*
|
| 234 |
+
*Hardware de segunda mano. Software libre. AI para todos.*
|
gemma4/bench_gemma4.sh
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -uo pipefail
|
| 3 |
+
|
| 4 |
+
MODELS=("gemma4:e2b" "gemma4:e4b" "gemma4:26b-a4b")
|
| 5 |
+
PROMPT="Explica qué es un pipeline de MLOps en 3 pasos"
|
| 6 |
+
OUT="gemma4_rocm_bench.md"
|
| 7 |
+
|
| 8 |
+
printf "| Modelo | tok/s (gen) | Duración | tok/s (prompt) | Fallback CPU/RAM | Estado |\n|--------|-------------|----------|----------------|------------------|--------|\n" > "$OUT"
|
| 9 |
+
|
| 10 |
+
for m in "${MODELS[@]}"; do
|
| 11 |
+
echo ">>> Descargando $m..."
|
| 12 |
+
if ! ollama pull "$m" >/dev/null 2>&1; then
|
| 13 |
+
echo "[SKIP] $m no existe en el registro."
|
| 14 |
+
printf "| %s | N/A | N/A | N/A | N/A | Tag inválido |\n" "$m" >> "$OUT"
|
| 15 |
+
continue
|
| 16 |
+
fi
|
| 17 |
+
|
| 18 |
+
echo ">>> Ejecutando $m..."
|
| 19 |
+
raw=$(ollama run "$m" "$PROMPT" --verbose 2>&1) || true
|
| 20 |
+
|
| 21 |
+
tok_s=$(echo "$raw" | grep -i "eval rate:" | awk '{print $3}')
|
| 22 |
+
dur=$(echo "$raw" | grep -i "eval duration:" | awk '{print $3}')
|
| 23 |
+
p_tok=$(echo "$raw" | grep -i "prompt eval rate:" | awk '{print $4}')
|
| 24 |
+
cpu_fall=$(echo "$raw" | grep -ic "offload\|system\|cpu" || true)
|
| 25 |
+
|
| 26 |
+
st="GPU"
|
| 27 |
+
[[ $cpu_fall -gt 0 ]] && st="Partial/CPU"
|
| 28 |
+
[[ -z $tok_s ]] && { st="Fallo/Timeout"; tok_s="0"; dur="0"; p_tok="0"; }
|
| 29 |
+
|
| 30 |
+
printf "| %s | %s | %s | %s | %s | %s |\n" "$m" "${tok_s}" "${dur}" "${p_tok}" "$([ $cpu_fall -gt 0 ] && echo "Sí" || echo "No")" "$st" >> "$OUT"
|
| 31 |
+
echo "[OK] $m -> ${tok_s} tok/s"
|
| 32 |
+
done
|
| 33 |
+
|
| 34 |
+
echo -e "\nResultados guardados en $OUT"
|
| 35 |
+
cat "$OUT"
|
gemma4/gemma4_benchmark_results.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gemma 4 Benchmark - AMD RX 6700 XT + ROCm
|
| 2 |
+
**Date:** 2026-04-04 23:07
|
| 3 |
+
**Hardware:** AMD Ryzen 5 5600G | RX 6700 XT 12GB | 16GB RAM
|
| 4 |
+
**OS:** Pop!_OS 24.04 LTS
|
| 5 |
+
**ROCm:** HSA_OVERRIDE_GFX_VERSION=10.3.0 (gfx1031 -> gfx1030)
|
| 6 |
+
**Ollama:** 0.20.2
|
| 7 |
+
|
| 8 |
+
| Model | Prefill (tok/s) | Decode (tok/s) | GPU Used |
|
| 9 |
+
|-------|----------------|----------------|----------|
|
| 10 |
+
| gemma4:e2b | 1022.39 | 85.00 | ROCm ✅ |
|
| 11 |
+
| gemma4:e4b | 697.91 | 57.34 | ROCm ✅ |
|
| 12 |
+
| gemma4:26b | 157.94 | 10.70 | ROCm ✅ |
|
| 13 |
+
|
| 14 |
+
## Notas
|
| 15 |
+
- Promedio de 3 runs por modelo
|
| 16 |
+
- Prompt usado: "Explain what MLOps is in 3 steps"
|
| 17 |
+
- gfx1031 requiere HSA_OVERRIDE_GFX_VERSION=10.3.0 para ROCm
|
| 18 |
+
- Modelos descargados en: $OLLAMA_MODELS
|
| 19 |
+
|
| 20 |
+
## Comparativa vs documento de referencia
|
| 21 |
+
| Hardware | Decode 8B aprox | Precio aprox MXN |
|
| 22 |
+
|----------|----------------|-----------------|
|
| 23 |
+
| RX 6700 XT (este benchmark) | TBD | ~hardware existente |
|
| 24 |
+
| Mac Mini M4 16GB | 25-40 tok/s | ~23,000 MXN |
|
| 25 |
+
| RTX 3070 12GB | 50-80 tok/s | ~10,000 MXN usado |
|