AI-Modell-Deployment auf GPU-Servern: NVIDIA CUDA Anleitung
NVIDIA-Treiberinstallation, CUDA-Toolkit, nvidia-container-toolkit, Modell-Serving mit vLLM, GPU-Monitoring und AI-Modell-Deployment mit Docker Anleitung.
Inhaltsverzeichnis
AI-Modell-Deployment auf GPU-Servern: NVIDIA CUDA Anleitung
GPU-Server sind für den Betrieb von KI-Modellen in Produktionsumgebungen unverzichtbar. Diese Anleitung behandelt alles von der NVIDIA-Treiberinstallation über die CUDA-Konfiguration, Docker-GPU-Integration bis hin zum hochleistungsfähigen Modell-Serving mit vLLM.
GPU-Server-Anforderungen
| Komponente | Minimum | Empfohlen |
|---|---|---|
| GPU | NVIDIA T4 (16 GB) | NVIDIA A100 (40/80 GB) |
| RAM | 32 GB | 64 GB+ |
| Festplatte | 100 GB SSD | 500 GB NVMe |
| OS | Ubuntu 22.04 LTS | Ubuntu 22.04/24.04 LTS |
| CUDA | 12.0+ | 12.4+ |
NVIDIA-Treiberinstallation
Zuerst vorhandene Treiber entfernen und den neuen installieren:
# Vorhandene NVIDIA-Treiber entfernen
sudo apt-get purge nvidia-* -y
sudo apt-get autoremove -y
# Systemaktualisierung
sudo apt-get update && sudo apt-get upgrade -y
# NVIDIA-Treiber-Repository hinzufügen
sudo apt-get install -y linux-headers-$(uname -r)
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:graphics-drivers/ppa -y
sudo apt-get update
# Empfohlenen Treiber prüfen
ubuntu-drivers devices
# NVIDIA-Treiber installieren
sudo apt-get install -y nvidia-driver-550
sudo reboot
Nach der Installation überprüfen:
# Treiberversion und GPU-Informationen
nvidia-smi
CUDA-Toolkit-Installation
# CUDA-Keyring hinzufügen
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
# CUDA-Toolkit installieren
sudo apt-get install -y cuda-toolkit-12-4
# PATH-Konfiguration
echo 'export PATH=/usr/local/cuda-12.4/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
# Überprüfung
nvcc --version
NVIDIA Container Toolkit
Das nvidia-container-toolkit wird benötigt, um GPUs in Docker-Containern zu verwenden:
# NVIDIA Container Toolkit Repository
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
# Docker-Runtime konfigurieren
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Test
sudo docker run --rm --gpus all nvidia/cuda:12.4.0-base-ubuntu22.04 nvidia-smi
Modell-Serving mit vLLM
vLLM ist eine Hochdurchsatz-LLM-Inference-Engine. Sie optimiert die Speichernutzung mit PagedAttention-Technologie.
vLLM mit Docker
docker run -d \
--name vllm \
--gpus all \
-p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env HUGGING_FACE_HUB_TOKEN=$HF_TOKEN \
vllm/vllm-openai:latest \
--model meta-llama/Meta-Llama-3.1-8B-Instruct \
--max-model-len 4096 \
--gpu-memory-utilization 0.9
Docker Compose mit vLLM
version: '3.8'
services:
vllm:
image: vllm/vllm-openai:latest
container_name: vllm-server
ports:
- "8000:8000"
volumes:
- huggingface_cache:/root/.cache/huggingface
environment:
- HUGGING_FACE_HUB_TOKEN=${HF_TOKEN}
command: >
--model meta-llama/Meta-Llama-3.1-8B-Instruct
--max-model-len 4096
--gpu-memory-utilization 0.9
--tensor-parallel-size 1
--dtype auto
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
restart: unless-stopped
volumes:
huggingface_cache:
vLLM-API-Nutzung
vLLM bietet eine OpenAI-kompatible API:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct",
"messages": [
{"role": "system", "content": "Du bist ein hilfreicher Assistent."},
{"role": "user", "content": "Was ist Docker?"}
],
"max_tokens": 512,
"temperature": 0.7
}'
Python-Nutzung mit vLLM
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="not-needed"
)
response = client.chat.completions.create(
model="meta-llama/Meta-Llama-3.1-8B-Instruct",
messages=[
{"role": "system", "content": "Du bist ein Linux-Experte."},
{"role": "user", "content": "Wie konfiguriert man RAID?"}
],
max_tokens=1024,
temperature=0.7
)
print(response.choices[0].message.content)
Multi-GPU-Konfiguration
# Tensor-Parallelismus mit mehreren GPUs
docker run -d \
--name vllm-multi \
--gpus all \
-p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:latest \
--model meta-llama/Meta-Llama-3.1-70B-Instruct \
--tensor-parallel-size 4 \
--max-model-len 4096 \
--gpu-memory-utilization 0.9
GPU-Monitoring
Überwachung mit nvidia-smi
# Aktueller Status
nvidia-smi
# Kontinuierliche Überwachung (jede Sekunde)
watch -n 1 nvidia-smi
# Nur GPU-Auslastung und Speicher
nvidia-smi --query-gpu=index,name,utilization.gpu,memory.used,memory.total,temperature.gpu --format=csv -l 1
Monitoring mit Prometheus + Grafana
version: '3.8'
services:
dcgm-exporter:
image: nvcr.io/nvidia/k8s/dcgm-exporter:3.3.5-3.4.0-ubuntu22.04
container_name: dcgm-exporter
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
ports:
- "9400:9400"
restart: unless-stopped
Sicherheit und Optimierung
GPU Persistence Mode
# Persistence-Modus aktivieren (niedrigere Latenz)
sudo nvidia-smi -pm 1
# GPU-Taktrate fixieren
sudo nvidia-smi -lgc 1410,1410
# Leistungslimit setzen
sudo nvidia-smi -pl 300
Betreiben Sie Ihre KI-Modelle mit hoher Leistung auf REXE GPU-Servern mit NVIDIA A100/H100 GPUs. Kontaktieren Sie uns für professionelle GPU-Server-Lösungen.
Verwandte Artikel
Ollama Installation: Lokale LLM-Ausführungsanleitung
Ollama-Installation, lokale LLM-Modelle ausführen (Llama 3, Mistral, Gemma), API-Nutzung, Modellverwaltung, GPU-Beschleunigung und Docker-Deployment.
Open WebUI Einrichtung: ChatGPT-ähnliche Oberfläche für lokale KI
Open WebUI Installation mit Docker, Ollama-Integration, Benutzerverwaltung, RAG (Dokumentenabfrage), Modellverwaltung, benutzerdefinierte Prompts und Mehrbenutzersupport.
Stable Diffusion Einrichtung: Self-Hosted Bilderzeugung
Stable Diffusion Installation, AUTOMATIC1111 und ComfyUI Oberflächen, Modell-Download, LoRA-Training, ControlNet-Nutzung und Docker Self-Hosted Bilderzeugung Anleitung.