Llama.cpp: Unterschied zwischen den Versionen
KKeine Bearbeitungszusammenfassung |
KKeine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
'''Hinweis:''' Alle Pfade beziehen sich auf <code>/home/hendrik/Programme/llama.cpp/</code> als Installationsverzeichnis. Bitte entsprechend anpassen. | |||
== Beschreibung == | == Beschreibung == | ||
| Zeile 6: | Zeile 8: | ||
== Download == | == Download == | ||
'''llama.cpp:''' | |||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
git clone https://github.com/ggml-org/llama.cpp | git clone https://github.com/ggml-org/llama.cpp ~/Programme/llama.cpp | ||
cd llama.cpp | cd ~/Programme/llama.cpp | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''ik_llama.cpp:''' | |||
<syntaxhighlight lang="bash" line="1"> | |||
git clone https://github.com/ikawrakow/ik_llama.cpp ~/Programme/llama.cpp | |||
cd ~/Programme/llama.cpp | |||
</syntaxhighlight> | |||
== Installation == | == Installation == | ||
=== | === Voraussetzungen === | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
sudo dnf install libcurl-devel -y | sudo dnf install libcurl-devel -y | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{| class="wikitable" | |||
|- | |||
! GPU !! Architektur !! Standard-Target | |||
|- | |||
| RX 7900 XTX || gfx1100 || '''ja''' | |||
|- | |||
| Strix Halo || gfx1151 || '''ja''' | |||
|- | |||
| MI50 / MI60 || gfx906 || separater Build (siehe unten) | |||
|} | |||
=== Vulkan Build === | |||
''Gilt für llama.cpp und ik_llama.cpp.'' | |||
[https://vulkan.lunarg.com/sdk/home Vulkan SDK] herunterladen, entpacken, ins Verzeichnis wechseln und <code>source setup-env.sh</code> ausführen. Dann ins llama.cpp-Verzeichnis wechseln: | [https://vulkan.lunarg.com/sdk/home Vulkan SDK] herunterladen, entpacken, ins Verzeichnis wechseln und <code>source setup-env.sh</code> ausführen. Dann ins llama.cpp-Verzeichnis wechseln: | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
source | source ~/Programme/Vulkan_SDK/1.4.335.0/setup-env.sh | ||
cd | cd ~/Programme/llama.cpp/ | ||
rm -R build-vulkan | rm -R build-vulkan | ||
cmake -B build-vulkan -DGGML_VULKAN=1 -DGGML_RPC=ON # llama.cpp | cmake -B build-vulkan -DGGML_VULKAN=1 -DGGML_RPC=ON # llama.cpp | ||
| Zeile 37: | Zeile 59: | ||
=== ROCm Build (getestet mit ROCm 6.4.3 und 7.1.0) === | === ROCm Build (getestet mit ROCm 6.4.3 und 7.1.0) === | ||
==== ROCm Quick-Install ==== | |||
==== ROCm Quick-Install === | |||
Alle Befehle von der [https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/quick-start.html ROCm Quick-Start Seite] ausführen. | Alle Befehle von der [https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/quick-start.html ROCm Quick-Start Seite] ausführen. | ||
| Zeile 67: | Zeile 78: | ||
echo 'export HSA_OVERRIDE_GFX_VERSION=9.0.6' >> ~/.bashrc # Für MI50/MI60 | echo 'export HSA_OVERRIDE_GFX_VERSION=9.0.6' >> ~/.bashrc # Für MI50/MI60 | ||
source ~/.bashrc | source ~/.bashrc | ||
sudo dnf install rocwmma-devel -y | sudo dnf install rocwmma-devel -y | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Zeile 76: | Zeile 84: | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
cd | cd ~/Programme/llama.cpp/ && git pull && rm -R build-rocm-old && cp -R build-rocm build-rocm-old | ||
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -B build-rocm -DGGML_HIP=ON -DGGML_RPC=ON -DAMDGPU_TARGETS=gfx1100 -DCMAKE_BUILD_TYPE=Release | HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -B build-rocm -DGGML_HIP=ON -DGGML_RPC=ON -DAMDGPU_TARGETS=gfx1100,gfx1151 -DCMAKE_BUILD_TYPE=Release | ||
cmake --build build-rocm --config Release -- -j 16 | cmake --build build-rocm --config Release -- -j 16 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Für | '''Für MI50 (gfx906) — separater Build:''' | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
cd ~/Programme/llama.cpp/ && rm -R build-rocm-old && cp -R build-rocm build-rocm-old | |||
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" | HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -B build-rocm -DGGML_HIP=ON -DGGML_RPC=ON -DAMDGPU_TARGETS=gfx906 -DCMAKE_BUILD_TYPE=Release | ||
cmake --build build-rocm --config Release -- -j 16 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Zeile 94: | Zeile 100: | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
cd | cd ~/Programme/llama.cpp/ && rm -R build-rocm-old && cp -R build-rocm build-rocm-old | ||
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -B build-rocm -DGGML_HIP=ON -DGGML_RPC=ON -DAMDGPU_TARGETS=gfx1100,gfx1151 -DCMAKE_BUILD_TYPE=Release | HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -B build-rocm -DGGML_HIP=ON -DGGML_RPC=ON -DAMDGPU_TARGETS=gfx1100,gfx1151 -DCMAKE_BUILD_TYPE=Release | ||
cmake --build build-rocm --config Release -- -j 16 | cmake --build build-rocm --config Release -- -j 16 | ||
</syntaxhighlight> | |||
=== Build prüfen === | |||
<syntaxhighlight lang="bash" line="1"> | |||
./build/bin/llama-server --version | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Zeile 118: | Zeile 130: | ||
[Service] | [Service] | ||
Type=simple | Type=simple | ||
User= | User=hendrik | ||
Group= | Group=hendrik | ||
WorkingDirectory=/home/ | WorkingDirectory=/home/hendrik/Programme/llama.cpp/build/bin | ||
# Multi-GPU Konfiguration | # Multi-GPU Konfiguration | ||
| Zeile 129: | Zeile 141: | ||
# Server mit optimalen Multi-GPU Einstellungen | # Server mit optimalen Multi-GPU Einstellungen | ||
ExecStart=/home/ | ExecStart=/home/hendrik/Programme/llama.cpp/build/bin/llama-server \ | ||
-m /home/ | -m /home/hendrik/models/model.gguf \ | ||
--split-mode row \ | --split-mode row \ | ||
--tensor-split 0.5,0.5 \ | --tensor-split 0.5,0.5 \ | ||
| Zeile 206: | Zeile 218: | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
cd | cd ~/Programme/llama.cpp/ | ||
./build/bin/rpc-server --host 0.0.0.0 | ./build/bin/rpc-server --host 0.0.0.0 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Zeile 218: | Zeile 230: | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
./llama-server \ | ./llama-server \ | ||
--model | --model ~/.lmstudio/models/unsloth/Step-3.7-Flash-GGUF/Step-3.7-Flash-UD-IQ4_XS-00001-of-00003.gguf \ | ||
- | -ngl 99 \ | ||
--rpc localhost:50052,192.168.1.19:50052 | --rpc localhost:50052,192.168.1.19:50052 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Zeile 242: | Zeile 254: | ||
[Service] | [Service] | ||
Type=simple | Type=simple | ||
User= | User=hendrik | ||
Group= | Group=hendrik | ||
WorkingDirectory=/home/ | WorkingDirectory=/home/hendrik/Programme/llama.cpp/build/bin | ||
Environment="HIP_VISIBLE_DEVICES=0" | Environment="HIP_VISIBLE_DEVICES=0" | ||
| Zeile 250: | Zeile 262: | ||
Environment="LD_LIBRARY_PATH=/opt/rocm/lib" | Environment="LD_LIBRARY_PATH=/opt/rocm/lib" | ||
ExecStart=/home/ | ExecStart=/home/hendrik/Programme/llama.cpp/build/bin/rpc-server --host 0.0.0.0 | ||
Restart=always | Restart=always | ||
| Zeile 272: | Zeile 284: | ||
<syntaxhighlight lang="bash" line="1"> | <syntaxhighlight lang="bash" line="1"> | ||
cd ~/llama.cpp | cd ~/Programme/llama.cpp | ||
git pull | git pull | ||
cmake --build build --config Release -- -j $(nproc) | cmake --build build --config Release -- -j $(nproc) | ||
# | # Services neu starten falls aktiv | ||
sudo systemctl restart llama-server | sudo systemctl restart llama-server | ||
sudo systemctl restart llama-rpc # falls RPC-Service läuft | sudo systemctl restart llama-rpc # falls RPC-Service läuft | ||
| Zeile 287: | Zeile 299: | ||
! Parameter !! Beschreibung | ! Parameter !! Beschreibung | ||
|- | |- | ||
| <code>-ngl 99</code> || Alle Layer auf GPU auslagern | | <code>-ngl 99</code> || Alle Layer auf GPU auslagern (Langform: <code>--gpu-layers</code>) | ||
|- | |- | ||
| <code>-fa 1</code> || Flash Attention aktivieren | | <code>-fa 1</code> || Flash Attention aktivieren | ||
Aktuelle Version vom 3. Juni 2026, 14:43 Uhr
Hinweis: Alle Pfade beziehen sich auf /home/hendrik/Programme/llama.cpp/ als Installationsverzeichnis. Bitte entsprechend anpassen.
Beschreibung
llama.cpp ist eine C/C++ Implementierung für Inference von Large Language Models (LLMs). Es unterstützt verschiedene Backends (CPU, Vulkan, ROCm, CUDA) und ermöglicht das Ausführen von quantisierten Modellen im GGUF-Format.
ik_llama.cpp ist ein optimierter Fork von llama.cpp mit zusätzlichen Performance-Verbesserungen und Unterstützung für neuere GPU-Architekturen (z.B. gfx1151 / Strix Halo).
Download
llama.cpp:
git clone https://github.com/ggml-org/llama.cpp ~/Programme/llama.cpp
cd ~/Programme/llama.cppik_llama.cpp:
git clone https://github.com/ikawrakow/ik_llama.cpp ~/Programme/llama.cpp
cd ~/Programme/llama.cppInstallation
Voraussetzungen
sudo dnf install libcurl-devel -y| GPU | Architektur | Standard-Target |
|---|---|---|
| RX 7900 XTX | gfx1100 | ja |
| Strix Halo | gfx1151 | ja |
| MI50 / MI60 | gfx906 | separater Build (siehe unten) |
Vulkan Build
Gilt für llama.cpp und ik_llama.cpp.
Vulkan SDK herunterladen, entpacken, ins Verzeichnis wechseln und source setup-env.sh ausführen. Dann ins llama.cpp-Verzeichnis wechseln:
source ~/Programme/Vulkan_SDK/1.4.335.0/setup-env.sh
cd ~/Programme/llama.cpp/
rm -R build-vulkan
cmake -B build-vulkan -DGGML_VULKAN=1 -DGGML_RPC=ON # llama.cpp
# cmake -B build-vulkan -DLLAMA_VULKAN=on -DGGML_RPC=ON # ik_llama.cpp
cmake --build build-vulkan --config Release -- -j $(nproc)ROCm Build (getestet mit ROCm 6.4.3 und 7.1.0)
ROCm Quick-Install
Alle Befehle von der ROCm Quick-Start Seite ausführen.
Wichtig für MI50 (gfx906) mit ROCm 6.4:
Vor dem Reboot die rocblas-Bibliothek aus dem AUR ergänzen:
- rocblas aus dem AUR herunterladen (Version 6.4)
- Entpacken
- Alle Tensor-Dateien mit
gfx906im Namen vonrocblas-…/opt/rocm/lib/rocblas/librarynach/opt/rocm/lib/rocblas/librarykopieren - Reboot
- Prüfen:
sudo update-alternatives --display rocm
ROCm Umgebung einrichten (optional, bei Fehlern)
echo 'export LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export HSA_OVERRIDE_GFX_VERSION=9.0.6' >> ~/.bashrc # Für MI50/MI60
source ~/.bashrc
sudo dnf install rocwmma-devel -yllama.cpp kompilieren (ROCm)
cd ~/Programme/llama.cpp/ && git pull && rm -R build-rocm-old && cp -R build-rocm build-rocm-old
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -B build-rocm -DGGML_HIP=ON -DGGML_RPC=ON -DAMDGPU_TARGETS=gfx1100,gfx1151 -DCMAKE_BUILD_TYPE=Release
cmake --build build-rocm --config Release -- -j 16Für MI50 (gfx906) — separater Build:
cd ~/Programme/llama.cpp/ && rm -R build-rocm-old && cp -R build-rocm build-rocm-old
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -B build-rocm -DGGML_HIP=ON -DGGML_RPC=ON -DAMDGPU_TARGETS=gfx906 -DCMAKE_BUILD_TYPE=Release
cmake --build build-rocm --config Release -- -j 16ik_llama.cpp kompilieren (ROCm)
cd ~/Programme/llama.cpp/ && rm -R build-rocm-old && cp -R build-rocm build-rocm-old
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -B build-rocm -DGGML_HIP=ON -DGGML_RPC=ON -DAMDGPU_TARGETS=gfx1100,gfx1151 -DCMAKE_BUILD_TYPE=Release
cmake --build build-rocm --config Release -- -j 16Build prüfen
./build/bin/llama-server --versionKonfiguration
llama-server als systemd Service einrichten
Service-Datei erstellen:
sudo nano /etc/systemd/system/llama-server.serviceService-Datei Inhalt (Multi-GPU mit ROCm):
[Unit]
Description=Llama.cpp ROCm Multi-GPU Server
After=network.target
[Service]
Type=simple
User=hendrik
Group=hendrik
WorkingDirectory=/home/hendrik/Programme/llama.cpp/build/bin
# Multi-GPU Konfiguration
Environment="HIP_VISIBLE_DEVICES=0,1"
Environment="HSA_OVERRIDE_GFX_VERSION=9.0.6"
Environment="PATH=/opt/rocm/bin:/usr/local/bin:/usr/bin:/bin"
Environment="LD_LIBRARY_PATH=/opt/rocm/lib"
# Server mit optimalen Multi-GPU Einstellungen
ExecStart=/home/hendrik/Programme/llama.cpp/build/bin/llama-server \
-m /home/hendrik/models/model.gguf \
--split-mode row \
--tensor-split 0.5,0.5 \
-ngl 99 \
-fa 1 \
--host 0.0.0.0 \
--port 8080 \
-c 32768 \
-b 2048 \
-ub 2048 \
--threads 8 \
--parallel 1 \
--jinja
Restart=always
RestartSec=10
LimitNOFILE=65535
LimitMEMLOCK=infinity
StandardOutput=journal
StandardError=journal
SyslogIdentifier=llama-server
[Install]
WantedBy=multi-user.targetService aktivieren und starten:
sudo systemctl daemon-reload
sudo systemctl enable llama-server # Auto-Start beim Boot
sudo systemctl start llama-server
sudo systemctl status llama-server # Status prüfen
sudo journalctl -u llama-server -f # Logs verfolgenService verwalten:
sudo systemctl stop llama-server # Stoppen
sudo systemctl restart llama-server # Neustarten
sudo systemctl disable llama-server # Autostart deaktivierenManuelle Server-Starts
Multi-GPU (ROCm) — optimal:
HIP_VISIBLE_DEVICES=0,1 ./llama-server \
-m ~/models/model.gguf \
--split-mode row \
--tensor-split 0.5,0.5 \
-ngl 99 \
-fa 1 \
--host 0.0.0.0 \
--port 8080 \
-c 32768 \
-b 2048 \
-ub 2048 \
--threads 8 \
--parallel 1 \
--jinjaRPC — Verteiltes Inference über mehrere Hosts
Mit -DGGML_RPC=ON wird der rpc-server mitgebaut, der es ermöglicht, die Inferenz über das Netzwerk auf mehrere Maschinen zu verteilen. Jeder Remote-Host stellt seine GPU(s) über einen rpc-server zur Verfügung; der Main-Host verbindet sich darüber mit --rpc.
Voraussetzung: Auf allen Hosts muss llama.cpp mit -DGGML_RPC=ON kompiliert sein (siehe Build-Abschnitte oben). Die Netzwerkverbindung zwischen den Hosts muss bestehen.
1. RPC-Server auf allen Remote-Hosts starten
Auf jedem Host, der seine GPU zur Verfügung stellen soll:
cd ~/Programme/llama.cpp/
./build/bin/rpc-server --host 0.0.0.0Standardmäßig lauscht der rpc-server auf Port 50052. Mit --port kann ein anderer Port gewählt werden.
2. llama-server auf dem Main-Host starten
Auf dem Host, der die Inferenz koordiniert:
./llama-server \
--model ~/.lmstudio/models/unsloth/Step-3.7-Flash-GGUF/Step-3.7-Flash-UD-IQ4_XS-00001-of-00003.gguf \
-ngl 99 \
--rpc localhost:50052,192.168.1.19:50052Dabei ist localhost:50052 die lokale GPU und 192.168.1.19:50052 die Remote-GPU.
rpc-server als systemd Service (Remote-Host)
Service-Datei erstellen:
sudo nano /etc/systemd/system/llama-rpc.serviceService-Datei Inhalt:
[Unit]
Description=Llama.cpp RPC Server (Remote GPU)
After=network.target
[Service]
Type=simple
User=hendrik
Group=hendrik
WorkingDirectory=/home/hendrik/Programme/llama.cpp/build/bin
Environment="HIP_VISIBLE_DEVICES=0"
Environment="PATH=/opt/rocm/bin:/usr/local/bin:/usr/bin:/bin"
Environment="LD_LIBRARY_PATH=/opt/rocm/lib"
ExecStart=/home/hendrik/Programme/llama.cpp/build/bin/rpc-server --host 0.0.0.0
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=llama-rpc
[Install]
WantedBy=multi-user.targetAktivieren:
sudo systemctl daemon-reload
sudo systemctl enable --now llama-rpcUpdate
cd ~/Programme/llama.cpp
git pull
cmake --build build --config Release -- -j $(nproc)
# Services neu starten falls aktiv
sudo systemctl restart llama-server
sudo systemctl restart llama-rpc # falls RPC-Service läuftParameter-Referenz
| Parameter | Beschreibung |
|---|---|
-ngl 99 |
Alle Layer auf GPU auslagern (Langform: --gpu-layers)
|
-fa 1 |
Flash Attention aktivieren |
-c 32768 |
Kontextfenster-Größe |
-b 2048 |
Batch-Size |
-ub 2048 |
Physical USB batch size |
--split-mode row |
Tensor-Split-Modus (Multi-GPU) |
--tensor-split 0.5,0.5 |
Gleichmäßige Aufteilung auf 2 GPUs |
--parallel 1 |
Anzahl paralleler Sequenzen |
--jinja |
Jinja-Template-Support für Chat |
--rpc host:port,… |
RPC-Backends für verteiltes Inference |
-DGGML_RPC=ON |
CMake-Flag: RPC-Support einkompilieren |