benchmarks / gemma4 /README.md
gio5464's picture
Upload gemma4/README.md with huggingface_hub
cd50f31 verified
|
Raw
History Blame Contribute Delete
6.48 kB
---
tags:
- benchmark
- amd
- rocm
- gemma4
- local-llm
- linux
- spanish
- latam
language:
- es
- en
license: apache-2.0
---
# Gemma 4 on AMD RX 6700 XT + ROCm
> 🇲🇽 [Versión en Español](#versión-en-español) | 🇺🇸 [English Version](#english-version)
Benchmarks of Google's Gemma 4 (April 2026) running on AMD GPU with ROCm on Linux.
**This documentation doesn't exist in Spanish — for the LatAm community.**
---
## English Version
### Why this matters
Most local AI guides assume:
- NVIDIA GPU (CUDA)
- Apple Silicon (macOS)
- $1,500+ USD budget
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.
### Hardware
| Component | Detail |
|-----------|--------|
| GPU | AMD RX 6700 XT 12GB (gfx1031) |
| CPU | AMD Ryzen 5 5600G |
| RAM | 16GB |
| OS | Pop!_OS 24.04 LTS |
| Ollama | 0.20.2 |
| ROCm override | HSA_OVERRIDE_GFX_VERSION=10.3.0 |
### Results (average of 3 runs)
| Model | Prefill (tok/s) | Decode (tok/s) | VRAM | Status |
|-------|----------------|----------------|------|--------|
| gemma4:e2b | 1022.39 | 85.00 | ~2GB | ROCm ✅ full GPU |
| gemma4:e4b | 697.91 | 57.34 | ~4GB | ROCm ✅ full GPU |
| gemma4:26b | 157.94 | 10.70 | 12GB + RAM offload | ROCm ⚠️ partial |
> **Note:** Prefill varies between runs due to KV cache warming.
> Decode is the number that matters for user experience — very consistent.
### Platform comparison (decode ~4B models)
| Hardware | Decode tok/s | Price (approx USD) |
|----------|--------------|--------------------|
| **RX 6700 XT + ROCm (this repo)** | **57-85** | existing hardware |
| Mac Mini M4 16GB | 25-40 | ~$600 new |
| RTX 3070 12GB | 50-80 | ~$500 used |
**The RX 6700 XT doubles the Mac Mini M4 16GB in decode speed for models that fit in VRAM.**
### The gfx1031 problem
The RX 6700 XT reports `gfx1031` architecture, but ROCm doesn't officially support it.
Without the override, Ollama falls back to CPU (~3-5 tok/s).
**Fix:**
```bash
sudo mkdir -p /etc/systemd/system/ollama.service.d
sudo tee /etc/systemd/system/ollama.service.d/rocm-fix.conf << 'CONF'
[Service]
Environment="HSA_OVERRIDE_GFX_VERSION=10.3.0"
Environment="ROCR_VISIBLE_DEVICES=0"
CONF
sudo systemctl daemon-reload
sudo systemctl restart ollama
```
**Verify it worked:**
```bash
journalctl -u ollama -n 10 --no-pager | grep "AMD Radeon"
# Expected output:
# description="AMD Radeon RX 6700 XT" total="12.0 GiB" available="11.1 GiB"
```
### Full setup
```bash
# 1. Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# 2. Apply ROCm fix (see above)
# 3. Pull models
ollama pull gemma4:e2b # 2B - fast, fits easily
ollama pull gemma4:e4b # 4B - great quality, fits in VRAM
ollama pull gemma4:26b # 26B - requires RAM offload on 12GB
# 4. Run
ollama run gemma4:e4b "Hello, what is MLOps?"
```
### Run the benchmark yourself
```bash
chmod +x bench_gemma4.sh
./bench_gemma4.sh
```
Runs 3 iterations per model, saves results to `gemma4_benchmark_results.md`.
---
## Versión en Español
### Por qué esto importa
La mayoría de guías de AI local asumen:
- GPU NVIDIA (CUDA)
- Apple Silicon (macOS)
- Presupuesto de $1,500 USD o más
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.
### Hardware
| Componente | Detalle |
|------------|---------|
| GPU | AMD RX 6700 XT 12GB (gfx1031) |
| CPU | AMD Ryzen 5 5600G |
| RAM | 16GB |
| OS | Pop!_OS 24.04 LTS |
| Ollama | 0.20.2 |
| Override ROCm | HSA_OVERRIDE_GFX_VERSION=10.3.0 |
### Resultados (promedio de 3 corridas)
| Modelo | Prefill (tok/s) | Decode (tok/s) | VRAM | Estado |
|--------|----------------|----------------|------|--------|
| gemma4:e2b | 1022.39 | 85.00 | ~2GB | ROCm ✅ GPU completa |
| gemma4:e4b | 697.91 | 57.34 | ~4GB | ROCm ✅ GPU completa |
| gemma4:26b | 157.94 | 10.70 | 12GB + offload a RAM | ROCm ⚠️ parcial |
> **Nota:** El prefill varía entre corridas por el KV cache warming.
> El decode es el número relevante para experiencia de usuario y es muy consistente.
### Comparativa vs otras plataformas (decode modelos ~4B)
| Hardware | Decode tok/s | Precio aprox MXN |
|----------|-------------|-----------------|
| **RX 6700 XT + ROCm (este repo)** | **57-85** | hardware existente |
| Mac Mini M4 16GB | 25-40 | ~$23,000 MXN nuevo |
| RTX 3070 12GB | 50-80 | ~$10,000 MXN usado |
**La RX 6700 XT dobla en velocidad al Mac Mini M4 16GB en modelos que caben en VRAM.**
### El problema del gfx1031
La RX 6700 XT reporta arquitectura `gfx1031` pero ROCm no la tiene en su lista de soporte oficial.
Sin el override, Ollama cae a CPU (~3-5 tok/s).
**Fix:**
```bash
sudo mkdir -p /etc/systemd/system/ollama.service.d
sudo tee /etc/systemd/system/ollama.service.d/rocm-fix.conf << 'CONF'
[Service]
Environment="HSA_OVERRIDE_GFX_VERSION=10.3.0"
Environment="ROCR_VISIBLE_DEVICES=0"
CONF
sudo systemctl daemon-reload
sudo systemctl restart ollama
```
**Verificar que funcionó:**
```bash
journalctl -u ollama -n 10 --no-pager | grep "AMD Radeon"
# Output esperado:
# description="AMD Radeon RX 6700 XT" total="12.0 GiB" available="11.1 GiB"
```
### Setup completo
```bash
# 1. Instalar Ollama
curl -fsSL https://ollama.com/install.sh | sh
# 2. Aplicar fix de ROCm (ver arriba)
# 3. Descargar modelos
ollama pull gemma4:e2b # 2B - rápido, cabe fácil
ollama pull gemma4:e4b # 4B - buena calidad, cabe en VRAM
ollama pull gemma4:26b # 26B - requiere offload a RAM en 12GB
# 4. Correr
ollama run gemma4:e4b "Hola, explica qué es MLOps"
```
### Correr el benchmark tú mismo
```bash
chmod +x bench_gemma4.sh
./bench_gemma4.sh
```
Corre 3 iteraciones por modelo y guarda los resultados en `gemma4_benchmark_results.md`.
### Modelos probados
| Modelo | Parámetros | Tipo | ¿Cabe en 12GB? |
|--------|-----------|------|----------------|
| gemma4:e2b | 2B | Dense | ✅ GPU completa |
| gemma4:e4b | 4B | Dense | ✅ GPU completa |
| gemma4:26b | 26B (4B activos, MoE) | MoE | ⚠️ offload parcial |
---
## About / Sobre este repo
Made in CDMX with second-hand hardware and free software.
Hecho en CDMX con hardware de segunda mano y software libre.
*[Positronica Labs](https://github.com/G10hdz) — Building AI tools for Latin America.*
*Hardware de segunda mano. Software libre. AI para todos.*