> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-de/sprachmodelle/ollama.md).

# Ollama

Der einfachste Weg, LLMs lokal auf CLORE.AI-GPUs auszuführen.

{% hint style="info" %}
**Aktuelle Version: v0.6+** — Dieser Leitfaden behandelt Ollama v0.6 und neuer. Zu den wichtigsten neuen Funktionen gehören strukturierte Ausgaben (JSON-Schema-Durchsetzung), ein OpenAI-kompatibler Embeddings-Endpunkt (`/api/embed`), sowie paralleles Laden von Modellen (mehrere Modelle gleichzeitig ohne Auslagerung ausführen). Siehe [Neu in v0.6+](#new-in-v06) für Details.
{% endhint %}

{% hint style="success" %}
Alle Beispiele können auf GPU-Servern ausgeführt werden, die über [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

## Serveranforderungen

| Parameter | Minimum       | Empfohlen   |
| --------- | ------------- | ----------- |
| RAM       | 8 GB          | 16 GB+      |
| VRAM      | 6 GB          | 8 GB+       |
| Netzwerk  | 100 Mbit/s    | 500 Mbit/s+ |
| Startzeit | \~30 Sekunden | -           |

{% hint style="info" %}
Ollama ist leichtgewichtig und funktioniert auf den meisten GPU-Servern. Für größere Modelle (13B+) wählen Sie Server mit 16 GB+ RAM und 12 GB+ VRAM.
{% endhint %}

## Warum Ollama?

* **Einrichtung mit einem Befehl** - Kein Python, keine Abhängigkeiten
* **Modellbibliothek** - Modelle herunterladen mit `ollama pull`
* **OpenAI-kompatible API** - Direkter Ersatz
* **GPU-Beschleunigung** - Automatische CUDA-Erkennung
* **Mehrere Modelle** - Mehrere Modelle gleichzeitig ausführen (v0.6+)

## Schnellbereitstellung auf CLORE.AI

**Docker-Image:**

```
ollama/ollama
```

**Ports:**

```
22/tcp
11434/http
```

**Befehl:**

```bash
ollama serve
```

### Funktion überprüfen

Nach der Bereitstellung finden Sie Ihre `http_pub` URL in **Meine Bestellungen** und testen Sie:

```bash
# Ersetzen Sie dies durch Ihre tatsächliche http_pub-URL
curl https://your-http-pub.clorecloud.net/

# Erwartete Antwort: "Ollama is running"
```

{% hint style="warning" %}
Wenn Sie HTTP 502 erhalten, warten Sie 30–60 Sekunden – der Dienst startet noch.
{% endhint %}

## Auf Ihren Dienst zugreifen

Wenn auf CLORE.AI bereitgestellt, greifen Sie auf Ihre Ollama-Instanz über die `http_pub` URL zu:

```bash
# Finden Sie Ihr http_pub unter Meine Bestellungen, dann:
curl https://your-http-pub.clorecloud.net/api/tags

# Für API-Aufrufe verwenden Sie Ihre http_pub-URL:
curl https://your-http-pub.clorecloud.net/api/chat -d '{
  "model": "llama3.2",
  "messages": [{"role": "user", "content": "Hello!"}],
  "stream": false
}'
```

{% hint style="info" %}
Alle `localhost:11434` Beispiele unten funktionieren bei Verbindung per SSH. Für externen Zugriff ersetzen Sie dies durch Ihre `https://your-http-pub.clorecloud.net/` URL.
{% endhint %}

## Installation

### Mit Docker (empfohlen)

```bash
docker run -d --gpus all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
```

### Manuelle Installation

```bash
curl -fsSL https://ollama.com/install.sh | sh
```

Dieser einzelne Befehl installiert die neueste Version von Ollama, richtet den systemd-Dienst ein und konfiguriert die GPU-Erkennung automatisch. Funktioniert auf Ubuntu, Debian, Fedora und den meisten modernen Linux-Distributionen.

## Modelle ausführen

### Herunterladen und ausführen

```bash
# Modell herunterladen
ollama pull llama3.2

# Interaktiven Chat starten
ollama run llama3.2

# Mit Prompt ausführen
ollama run llama3.2 "Explain quantum computing"
```

### Beliebte Modelle

| Modell              | Größe   | Anwendungsfall                 |
| ------------------- | ------- | ------------------------------ |
| `llama3.2`          | 3B      | Schnell, universell einsetzbar |
| `llama3.1`          | 8B      | Bessere Qualität               |
| `llama3.1:70b`      | 70B     | Beste Qualität                 |
| `mistral`           | 7B      | Schnell, gute Qualität         |
| `mixtral`           | 47B     | MoE, hohe Qualität             |
| `codellama`         | 7-34B   | Code-Generierung               |
| `deepseek-coder-v2` | 16B     | Am besten für Code             |
| `deepseek-r1`       | 7B-671B | Reasoning-Modell               |
| `deepseek-r1:32b`   | 32B     | Ausgewogenes Reasoning         |
| `qwen2.5`           | 7B      | Mehrsprachig                   |
| `qwen2.5:72b`       | 72B     | Beste Qwen-Qualität            |
| `phi4`              | 14B     | Microsofts neueste Version     |
| `gemma2`            | 9B      | Googles Modell                 |

### Modellvarianten

```bash
# Quantisierungsvarianten
ollama pull llama3.1:8b-instruct-q4_K_M   # 4-Bit (kleiner, schneller)
ollama pull llama3.1:8b-instruct-q8_0     # 8-Bit (bessere Qualität)
ollama pull llama3.1:8b-instruct-fp16     # Volle Präzision

# Größenvarianten
ollama pull llama3.1:8b    # 8 Milliarden Parameter
ollama pull llama3.1:70b   # 70 Milliarden Parameter

# Neue Modelle (v0.6+ Ära)
ollama pull deepseek-r1:7b      # Reasoning, preiswert
ollama pull deepseek-r1:14b     # Reasoning, effizient
ollama pull deepseek-r1:32b     # Reasoning, ausgewogen
ollama pull deepseek-r1:70b     # Reasoning, hohe Qualität
ollama pull qwen2.5:72b         # Größtes Qwen, höchste Qualität
ollama pull phi4                # Microsoft Phi-4 14B
```

## Neu in v0.6+

Ollama v0.6 führte mehrere wichtige Funktionen für produktive Workloads ein:

### Strukturierte Ausgaben (JSON-Schema)

Erzwingen Sie, dass Modellantworten einem bestimmten JSON-Schema entsprechen. Nützlich für Anwendungen, die zuverlässige, parsebare Ausgaben benötigen:

```bash
curl http://localhost:11434/api/chat -d '{
  "model": "llama3.2",
  "messages": [{"role": "user", "content": "Tell me about Canada."}],
  "format": {
    "type": "object",
    "properties": {
      "name": {"type": "string"},
      "capital": {"type": "string"},
      "population": {"type": "integer"},
      "languages": {
        "type": "array",
        "items": {"type": "string"}
      }
    },
    "required": ["name", "capital", "population", "languages"]
  },
  "stream": false
}'
```

Python-Beispiel mit strukturierten Ausgaben:

```python
from openai import OpenAI
import json

client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")

response = client.chat.completions.create(
    model="llama3.2",
    messages=[{"role": "user", "content": "List 3 programming languages with their main use cases"}],
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "languages",
            "schema": {
                "type": "object",
                "properties": {
                    "languages": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {"type": "string"},
                                "use_case": {"type": "string"},
                                "popularity_rank": {"type": "integer"}
                            }
                        }
                    }
                }
            }
        }
    }
)

data = json.loads(response.choices[0].message.content)
print(data)
```

### OpenAI-kompatibler Embeddings-Endpunkt (`/api/embed`)

Neu in v0.6+: der `/api/embed` Endpunkt ist vollständig OpenAI-kompatibel und unterstützt Batch-Eingaben:

```bash
# Einzelnes Text-Embedding
curl http://localhost:11434/api/embed -d '{
  "model": "nomic-embed-text",
  "input": "Hello world"
}'

# Batch-Embeddings (neu in v0.6)
curl http://localhost:11434/api/embed -d '{
  "model": "nomic-embed-text",
  "input": ["First document", "Second document", "Third document"]
}'
```

Der OpenAI-Client funktioniert direkt mit `/v1/embeddings`:

```python
from openai import OpenAI
import numpy as np

client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")

# Erst das Embedding-Modell herunterladen: ollama pull nomic-embed-text
response = client.embeddings.create(
    model="nomic-embed-text",
    input=["Hello world", "Goodbye world"]
)

emb1 = np.array(response.data[0].embedding)
emb2 = np.array(response.data[1].embedding)

# Kosinusähnlichkeit
similarity = np.dot(emb1, emb2) / (np.linalg.norm(emb1) * np.linalg.norm(emb2))
print(f"Similarity: {similarity:.4f}")
```

Beliebte Embedding-Modelle:

```bash
ollama pull nomic-embed-text      # 137M, schnell, gute Qualität
ollama pull mxbai-embed-large     # 335M, höhere Qualität
ollama pull all-minilm            # 23M, am schnellsten
```

### Paralleles Laden von Modellen

Vor v0.6 entlud Ollama ein Modell, um ein anderes zu laden. V0.6+ unterstützt das gleichzeitige Ausführen mehrerer Modelle, begrenzt nur durch den verfügbaren VRAM:

```bash
# Zwei Modelle gleichzeitig laden
ollama run llama3.2 &
ollama run deepseek-r1:7b &

# Prüfen, was läuft
curl http://localhost:11434/api/ps
```

Parallelität konfigurieren:

```bash
# Bis zu 4 gleichzeitig geladene Modelle erlauben
OLLAMA_MAX_LOADED_MODELS=4 ollama serve

# Jeder Runner in einem separaten Prozess (bessere Isolierung)
OLLAMA_NUM_PARALLEL=2 ollama serve
```

Das ist besonders nützlich für:

* A/B-Tests verschiedener Modelle
* Spezialisierte Modelle für unterschiedliche Aufgaben (Coding + Chat)
* Häufig verwendete Modelle im VRAM warm halten

## API-Nutzung

### Chat-Vervollständigung

```bash
# Über http_pub (externer Zugriff):
curl https://your-http-pub.clorecloud.net/api/chat -d '{
  "model": "llama3.2",
  "messages": [{"role": "user", "content": "Hello!"}],
  "stream": false
}'

# Über SSH-Tunnel (localhost):
curl http://localhost:11434/api/chat -d '{
  "model": "llama3.2",
  "messages": [{"role": "user", "content": "Hello!"}],
  "stream": false
}'
```

{% hint style="info" %}
Fügen Sie `"stream": false` hinzu, um die vollständige Antwort auf einmal statt als Streaming zu erhalten.
{% endhint %}

### OpenAI-kompatibler Endpunkt

```python
from openai import OpenAI

# Für externen Zugriff verwenden Sie Ihre http_pub-URL:
client = OpenAI(
    base_url="https://your-http-pub.clorecloud.net/v1",
    api_key="ollama"  # beliebiger String funktioniert
)

# Oder über SSH-Tunnel:
# client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")

response = client.chat.completions.create(
    model="llama3.2",
    messages=[
        {"role": "user", "content": "What is machine learning?"}
    ]
)

print(response.choices[0].message.content)
```

### Streaming

```python
stream = client.chat.completions.create(
    model="llama3.2",
    messages=[{"role": "user", "content": "Write a poem"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
```

### Embeddings

```bash
# Legacy-Endpunkt (funktioniert weiterhin)
curl http://localhost:11434/api/embeddings -d '{
  "model": "nomic-embed-text",
  "prompt": "Hello world"
}'

# Neuer v0.6+-Endpunkt (Batch-Unterstützung, OpenAI-kompatibel)
curl http://localhost:11434/api/embed -d '{
  "model": "nomic-embed-text",
  "input": ["Hello world", "Another text"]
}'
```

### Textgenerierung (Nicht-Chat)

```bash
curl https://your-http-pub.clorecloud.net/api/generate -d '{
  "model": "llama3.2",
  "prompt": "The meaning of life is",
  "stream": false
}'
```

## Vollständige API-Referenz

Alle Endpunkte funktionieren sowohl mit `http://localhost:11434` (via SSH) als auch mit `https://your-http-pub.clorecloud.net` (extern).

### Modellverwaltung

| Endpunkt       | Methode | Beschreibung                             |
| -------------- | ------- | ---------------------------------------- |
| `/api/tags`    | GET     | Alle heruntergeladenen Modelle auflisten |
| `/api/show`    | POST    | Modelldetails abrufen                    |
| `/api/pull`    | POST    | Ein Modell herunterladen                 |
| `/api/delete`  | DELETE  | Ein Modell entfernen                     |
| `/api/ps`      | GET     | Aktuell laufende Modelle auflisten       |
| `/api/version` | GET     | Ollama-Version abrufen                   |

#### Modelle auflisten

```bash
curl https://your-http-pub.clorecloud.net/api/tags
```

Antwort:

```json
{
  "models": [
    {"name": "llama3.2:latest", "size": 2019393189, "digest": "...", "modified_at": "..."}
  ]
}
```

#### Modelldetails anzeigen

```bash
curl https://your-http-pub.clorecloud.net/api/show -d '{"name": "llama3.2"}'
```

#### Modell per API herunterladen

```bash
curl https://your-http-pub.clorecloud.net/api/pull -d '{
  "name": "mistral:7b",
  "stream": false
}'
```

Antwort:

```json
{"status": "success"}
```

{% hint style="warning" %}
Große Modelle können mehrere Minuten zum Herunterladen brauchen. Bei sehr großen Modellen (30 GB+) sollten Sie SSH und die CLI verwenden: `ollama pull model-name`
{% endhint %}

#### Modell löschen

```bash
curl -X DELETE https://your-http-pub.clorecloud.net/api/delete -d '{"name": "mistral:7b"}'
```

#### Laufende Modelle auflisten

```bash
curl https://your-http-pub.clorecloud.net/api/ps
```

Antwort:

```json
{
  "models": [
    {"name": "llama3.2:latest", "size": 2019393189, "expires_at": "2025-01-25T12:00:00Z"}
  ]
}
```

#### Version abrufen

```bash
curl https://your-http-pub.clorecloud.net/api/version
```

Antwort:

```json
{"version": "0.6.8"}
```

### Inferenz-Endpunkte

| Endpunkt               | Methode | Beschreibung                                           |
| ---------------------- | ------- | ------------------------------------------------------ |
| `/api/generate`        | POST    | Textvervollständigung                                  |
| `/api/chat`            | POST    | Chat-Vervollständigung                                 |
| `/api/embeddings`      | POST    | Embeddings generieren (legacy)                         |
| `/api/embed`           | POST    | Embeddings v0.6+ generieren (Batch, OpenAI-kompatibel) |
| `/v1/chat/completions` | POST    | OpenAI-kompatibler Chat                                |
| `/v1/embeddings`       | POST    | OpenAI-kompatible Embeddings                           |

### Benutzerdefinierte Modell-Erstellung

Erstellen Sie benutzerdefinierte Modelle mit spezifischen System-Prompts über die API:

```bash
curl https://your-http-pub.clorecloud.net/api/create -d '{
  "name": "my-assistant",
  "modelfile": "FROM llama3.2\nSYSTEM You are a helpful coding assistant."
}'
```

## GPU-Konfiguration

### GPU-Nutzung prüfen

```bash
# Im Container oder Server
nvidia-smi

# Ollama zeigt die GPU in den Logs
ollama run llama3.2 --verbose
```

### Mehrere GPUs

Ollama verwendet automatisch verfügbare GPUs. Für eine bestimmte GPU:

```bash
CUDA_VISIBLE_DEVICES=0 ollama serve
```

### Speicherverwaltung

```bash
# GPU-Speicherlimit festlegen
OLLAMA_GPU_MEMORY=8GiB ollama serve

# Modell geladen halten
OLLAMA_KEEP_ALIVE=24h ollama serve

# Gleichzeitige Modelle zulassen (v0.6+)
OLLAMA_MAX_LOADED_MODELS=3 ollama serve
```

## Benutzerdefinierte Modelle (Modelfile)

Erstellen Sie benutzerdefinierte Modelle mit System-Prompts:

```dockerfile
# Modelfile
FROM llama3.2

SYSTEM You are a helpful coding assistant. Always provide code examples.

PARAMETER temperature 0.7
PARAMETER top_p 0.9
```

```bash
ollama create coding-assistant -f Modelfile
ollama run coding-assistant
```

## Als Dienst ausführen

### Systemd

```ini
# /etc/systemd/system/ollama.service
[Unit]
Description=Ollama-Dienst
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/ollama serve
Restart=always
Environment="OLLAMA_HOST=0.0.0.0"

[Install]
WantedBy=multi-user.target
```

```bash
systemctl enable ollama
systemctl start ollama
```

## Leistungstipps

1. **Geeignete Quantisierung verwenden**
   * Q4\_K\_M für Geschwindigkeit
   * Q8\_0 für Qualität
   * fp16 für maximale Qualität
2. **Modell an VRAM anpassen**
   * 8 GB: 7B-Modelle (Q4)
   * 16 GB: 13B-Modelle oder 7B (Q8)
   * 24 GB: 34B-Modelle (Q4)
   * 48 GB+: 70B-Modelle
3. **Modell geladen halten**

   ```bash
   OLLAMA_KEEP_ALIVE=1h ollama serve
   ```
4. **Schnelle SSD verbessert die Leistung**
   * Modellladen und KV-Cache profitieren von schnellem Speicher
   * Server mit NVMe-SSD können 2-3x bessere Leistung erreichen

## Benchmarks

### Generierungsgeschwindigkeit (Tokens/Sek.)

| Modell               | RTX 3060 | RTX 3090 | RTX 4090 | A100 40GB |
| -------------------- | -------- | -------- | -------- | --------- |
| Llama 3.2 3B (Q4)    | 120      | 160      | 200      | 220       |
| Llama 3.1 8B (Q4)    | 60       | 100      | 130      | 150       |
| Llama 3.1 8B (Q8)    | 45       | 80       | 110      | 130       |
| Mistral 7B (Q4)      | 70       | 110      | 140      | 160       |
| Mixtral 8x7B (Q4)    | -        | 35       | 55       | 75        |
| Llama 3.1 70B (Q4)   | -        | -        | 18       | 35        |
| DeepSeek-R1 7B (Q4)  | 65       | 105      | 135      | 155       |
| DeepSeek-R1 32B (Q4) | -        | -        | 22       | 42        |
| Qwen2.5 72B (Q4)     | -        | -        | 15       | 30        |
| Phi-4 14B (Q4)       | -        | 50       | 75       | 90        |

*Benchmarks aktualisiert im Januar 2026. Die tatsächlichen Geschwindigkeiten können je nach Serverkonfiguration variieren.*

### Zeit bis zum ersten Token (ms)

| Modell | RTX 3090 | RTX 4090 | A100 |
| ------ | -------- | -------- | ---- |
| 3B     | 50       | 35       | 25   |
| 7-8B   | 120      | 80       | 60   |
| 13B    | 250      | 150      | 100  |
| 34B    | 600      | 350      | 200  |
| 70B    | -        | 1200     | 500  |

### Kontextlänge vs. VRAM (Q4)

| Modell | 2K Kontext | 4K Kontext | 8K Kontext | 16K Kontext |
| ------ | ---------- | ---------- | ---------- | ----------- |
| 7B     | 5 GB       | 6 GB       | 8 GB       | 12 GB       |
| 13B    | 8 GB       | 10 GB      | 14 GB      | 22 GB       |
| 34B    | 20 GB      | 24 GB      | 32 GB      | 48 GB       |
| 70B    | 40 GB      | 48 GB      | 64 GB      | 96 GB       |

## GPU-Anforderungen

| Modell | Q4 VRAM | Q8 VRAM |
| ------ | ------- | ------- |
| 3B     | 3 GB    | 5 GB    |
| 7-8B   | 5 GB    | 9 GB    |
| 13B    | 8 GB    | 15 GB   |
| 34B    | 20 GB   | 38 GB   |
| 70B    | 40 GB   | 75 GB   |

## Kostenschätzung

Typische CLORE.AI-Marktplatzpreise:

| GPU                                                                                                | VRAM  | Preis/Tag  | Gut geeignet für     |
| -------------------------------------------------------------------------------------------------- | ----- | ---------- | -------------------- |
| [RTX 3090](https://clore.ai/rent-3090.html?utm_source=docs\&utm_medium=guide\&utm_campaign=ollama) | 24 GB | $0.30–1.00 | 13B-34B-Modelle      |
| [RTX 4090](https://clore.ai/rent-4090.html?utm_source=docs\&utm_medium=guide\&utm_campaign=ollama) | 24 GB | $0.50–2.00 | 34B-Modelle, schnell |
| RTX 4070                                                                                           | 12 GB | $0.20–0.50 | 7B-Modelle           |
| A100 80GB                                                                                          | 80 GB | $1.50–3.00 | 70B-Modelle          |

*Preise in USD/Tag. Die Tarife variieren je nach Anbieter — prüfen Sie* [*CLORE.AI Marketplace*](https://clore.ai/marketplace) *für aktuelle Preise.*

## Fehlerbehebung

### Modell wird nicht geladen

```bash
# Verfügbaren Speicher prüfen
nvidia-smi

# Kleinere Quantisierung ausprobieren
ollama pull llama3.1:8b-q4_0
```

### Langsame Generierung

```bash
# Prüfen, ob die GPU verwendet wird
ollama run llama3.2 --verbose

# Sicherstellen, dass CUDA verfügbar ist
nvidia-smi
```

### Verbindung abgelehnt

```bash
# Sicherstellen, dass der Server läuft
ollama serve

# Prüfen, ob an alle Schnittstellen gebunden wird
OLLAMA_HOST=0.0.0.0 ollama serve
```

### HTTP 502 bei http\_pub-URL

Das bedeutet, dass der Dienst noch startet. 30–60 Sekunden warten und erneut versuchen:

```bash
# Prüfen, ob der Dienst bereit ist
curl https://your-http-pub.clorecloud.net/

# Erwartet: "Ollama is running"
# Bei 502: warten und erneut versuchen
```

## Nächste Schritte

* [WebUI öffnen](/guides/guides_v2-de/sprachmodelle/open-webui.md) - Schöne Chat-Oberfläche für Ollama
* [vLLM](/guides/guides_v2-de/sprachmodelle/vllm.md) - Produktionsbereitstellung mit hohem Durchsatz
* [DeepSeek-R1](/guides/guides_v2-de/sprachmodelle/deepseek-r1.md) - Reasoning-Modell
* [DeepSeek-V3](/guides/guides_v2-de/sprachmodelle/deepseek-v3.md) - Bestes allgemeines Modell
* [Qwen2.5](/guides/guides_v2-de/sprachmodelle/qwen25.md) - Mehrsprachige Alternative
* [Text Generation WebUI](/guides/guides_v2-de/sprachmodelle/text-generation-webui.md) - Erweiterte Funktionen


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-de/sprachmodelle/ollama.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
