Der Zugriff kann mit Screensharing direkt auf dem Server erfolgen oder via Termial via SSH oder mit einer KI-App von einem beliebigen anderen Rechner.
Mit Tailscale VPN und einer Terminal-App ist der Zugriff auf ein grosses 70B Modell sogar mit dem iPhone von unterwegs möglich.
Dieser Beitrag schildert die Installation und die Bedienung im Terminal.
Client KI-Apps sind Thema eines separaten Blogs.
Installation der Ollama App
Am einfachsten ist die Installation der App. Siehe hier:
https://ollama.com/
https://ollama.com/download
Da sind die Modell gespeichert
~/.ollama/models
Anleitung zur Installation
Anleitung zur Installation und Verwendung via CLI
What is Ollama and how to use it: a quick guide
Hintergrundsdienst installieren
Ollama ist ein sehr gutes Werkzeug, um Llama-Modelle lokal auszuführen, und es als Hintergrunddienst auf macOS laufen zu lassen. Das ist für einen kontinuierlichen Betrieb ohne manuelle Eingriffe vorteilhaft.
Es gibt verschiedene Möglichkeiten Umgebundsvariabeln für Ollama zu laden. Als Dienst muss eine plist
Datei erstellt, welche dann in /Library/LaunchDaemons/
kopiert wird.
Für Ausführung mit Bindung in die Terminalsession, reicht es die .zshrc
Datei anzupassen. Ich möchte eine Ausführung bei Systemstart, unabhängig, ob ein Benutzer eingeloggt ist oder nicht.
Der plist
(Property List) Datei ist eine XML-Datei, die von macOS verwendet wird, um zu definieren, wie Anwendungen gestartet werden sollen.
plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ollama</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ollama</string>
<string>serve</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<!-- Change USER to your user's home directory -->
<string>/Users/USER</string>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
<key>LANG</key>
<string>de_DE.UTF-8</string>
<!-- Ollama accepts connections from all network interfaces -->
<key>OLLAMA_HOST</key>
<string>0.0.0.0</string>
<!-- Ollama keep model in memory for one week -->
<key>OLLAMA_KEEP_ALIVE</key>
<string>168h0m0s</string>
</dict>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/ollama/stdout.log</string>
<key>StandardErrorPath</key>
<string>/var/log/ollama/stderr.log</string>
</dict>
</plist>
- Label: Identifiziert den Dienst eindeutig. Hier ist es
com.ollama
. - ProgramArguments: Gibt den auszuführenden Befehl an. In diesem Fall ist es
ollama serve
. - RunAtLoad: Wenn auf
true
gesetzt, startet der Dienst, wenn das System hochfährt oder wenn derlaunchd
Prozess startet. - EnvironmentVariables: Legt Umgebungsvariablen für den Dienst fest. Hier sind
HOME
,PATH
,LANG
undOLLAMA_HOST
,OLLAMA_KEEP_ALIVE
enthalten. - HOME: Dies sollte auf das Benutzerverzeichnis gesetzt werden. Zum Beispiel, wenn Ihr Benutzername
john
ist, sollten Sie/Users/peter
in/Users/peter
ändern. - OLLAMA_HOST: muss auf 0.0.0.0 gesetzt werden, sonst ist Ollama nicht vom Netzwerk erreichbar.
- OLLAMA_KEEP_ALIVE: habe ich auf eine Woche gesetzt, verkürzt die Wartezeit. Wenn der Speicher knapp wird, können die Modelle manuell gestoppt werden
- KeepAlive: Stellt sicher, dass der Dienst neu startet, wenn er abstürzt oder beendet wird.
- StandardOutPath und StandardErrorPath: Definieren, wohin die Standardausgabe und Fehlerprotokolle des Dienstes geschrieben werden.
Schritte zur Einrichtung des Dienstes
- Erstellen der
plist
Datei: - Öffnen Sie das Terminal und verwenden Sienano
, um eine neue Datei zu erstellen:
nano com.ollama.plist
- Fügen Sie den oben genannten XML-Inhalt in die Datei ein.
- Speichern Sie die Datei, indem Sie
Ctrl+X
, dannY
und schließlichEnter
drücken. - Wichtig: Ändern Sie das
HOME
Verzeichnis im AbschnittEnvironmentVariables
, um das Benutzerverzeichnis Ihres Benutzers anzupassen.
2. Platzieren der plist
Datei:
- Verschieben Sie die
plist
Datei nach/Library/LaunchDaemons/
für einen systemweiten Dienst oder nach~/Library/LaunchAgents/
für einen benutzerspezifischen Dienst. Verwenden Siesudo
für die systemweite Platzierung:
sudo cp com.ollama.plist /Library/LaunchDaemons/
3. Berechtigungen setzen: — Stellen Sie sicher, dass die Datei die richtigen Berechtigungen hat:
sudo chown root:wheel /Library/LaunchDaemons/com.ollama.plist
sudo chmod 644 /Library/LaunchDaemons/com.ollama.plist
4. Dienst laden:
- Laden Sie den Dienst in
launchd
:
sudo launchctl load /Library/LaunchDaemons/com.ollama.plist
5. Dienst starten:
- Wenn Sie den Dienst sofort starten möchten:
sudo launchctl start com.ollama
6. Dienst überprüfen:
- Überprüfen Sie, ob der Dienst läuft:
sudo launchctl list | grep com.ollama
Kompatibilität
- Getestet mit macOS 15.2 Sequoia. Stellen Sie sicher, dass Ihr System die Mindestanforderungen für Ollama erfüllt, die normalerweise macOS 11 Big Sur oder höher umfassen.
Zusätzliche Hinweise
- Protokollierung: Die Protokolle für
ollama
werden in/var/log/ollama/stdout.log
und/var/log/ollama/stderr.log
geschrieben. Stellen Sie sicher, dass diese Verzeichnisse existieren oder erstellen Sie sie:
sudo mkdir -p /var/log/ollama
sudo chown root:wheel /var/log/ollama
sudo chmod 755 /var/log/ollama
- Dienst entladen: Wenn Sie den Dienst stoppen oder entfernen müssen:
sudo launchctl stop com.ollama
sudo launchctl unload /Library/LaunchDaemons/com.ollama.plist
Durch Befolgen dieser Schritte und Anpassen des HOME
Verzeichnisses nach Bedarf können Sie sicherstellen, dass ollama
als Hintergrunddienst auf Ihrem macOS-System läuft, automatisch beim Start startet und seine Aktivitäten zur Fehlerbehebung oder Überwachung protokolliert.
Anpassung der .zshrc
Datei
Meine .zshrc
Datei schaut so aus:
pp@MacStudio2025 ~ % cat .zshrc
# Terminal Prompt
# `%<n>c` to show the last `n` components of the working directory
PROMPT="%n@%m %2c >"
# Terminal Prompt
PROMPT="%n@%m %2c >"
# `%n`: Your username.
# `%m`: The hostname of your computer (up to the first dot).
# `%<n>c` to show the last `n` components of the working directory
# `%#`: Shows `#` if you are root, and `%` otherwise.
# Start Ollama Dienst
alias olstart="sudo launchctl start com.ollama"
# Status Ollama Dienst
alias olstatus="sudo launchctl list | grep com.ollama"
# Stop Ollama Dienst
alias olstop="sudo launchctl stop com.ollama"
# Load Ollama Dienst
alias olload="sudo launchctl load /Library/LaunchDaemons/com.ollama.plist"
# Unload Ollama Dienst
alias olunload="sudo launchctl unload /Library/LaunchDaemons/com.ollama.plist"
# Start FileMaker Server
alias fmsstart="sudo launchctl start com.filemaker.fms"
# Stop FileMaker Server
alias fmsstop="sudo launchctl stop com.filemaker.fms"
# Ollama accepts connections from all network interfaces
export OLLAMA_HOST=0.0.0.0
# Ollama keep model in memory for one week
export OLLAMA_KEEP_ALIVE=168h0m0s
Mit den Abkürzungen kann ich Ollama einfach manuell starten und stoppen. Ich bin mir das von FileMaker Server so gewohnt, die Abkürzungen für den FileMaker Server sind auch enthalten.
Die Umgebungsvariabeln für Ollama sind hier nicht nötig und dienen nur zur Illustration.
Ollama via Terminal verwenden
CLI Reference
https://github.com/ollama/ollama#cli-reference
# Pull a model
ollama pull llama3.2
This command can also be used to update a local model. Only the diff will be pulled.
# Remove a model
ollama rm llama3.2
# For multiline input, you can wrap text with `"""`:
>>> """Hello,
... world!
... """
I'm a basic program that prints the famous "Hello, world!" message to the console.
# Multimodal models
ollama run llava "What's in this image? /Users/jmorgan/Desktop/smile.png"
# Pass the prompt as an argument
ollama run llama3.2 "Summarize this file: $(cat README.md)"
# Show model information
ollama show llama3.2
# List models on your computer
ollama list
# List which models are currently loaded
ollama ps
# Stop a model which is currently running
ollama stop llama3.2
# Start Ollama
# is used when you want to start ollama
# without running the desktop application.
ollama serve
Modelle
Hier finden sich die genauen Bezeichnungen, welche benötigt werden, um ein Modell auszuführen.
https://ollama.com/search
Anleitungen
What is Ollama and how to use it: a quick guide
Ollama commands: How to use Ollama in the command line
Beispiele
pp@MacBookPro2023 ~ % ollama help
Large language model runner
Usage:
ollama [flags]
ollama [command]
Available Commands:
serve Start ollama
create Create a model from a Modelfile
show Show information for a model
run Run a model
stop Stop a running model
pull Pull a model from a registry
push Push a model to a registry
list List models
ps List running models
cp Copy a model
rm Remove a model
help Help about any command
Flags:
-h, --help help for ollama
-v, --version Show version information
Use "ollama [command] --help" for more information about a command.
pp@MacBookPro2023 ~ % ollama run --help
Run a model
Usage:
ollama run MODEL [PROMPT] [flags]
Flags:
--format string Response format (e.g. json)
-h, --help help for run
--insecure Use an insecure registry
--keepalive string Duration to keep a model loaded (e.g. 5m)
--nowordwrap Don't wrap words to the next line automatically
--verbose Show timings for response
Environment Variables:
OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434)
OLLAMA_NOHISTORY Do not preserve readline history
pp@MacBookPro2023 ~ % ollama run llama3.2
>>> /?
Available Commands:
/set Set session variables
/show Show model information
/load <model> Load a session or model
/save <model> Save your current session
/clear Clear session context
/bye Exit
/?, /help Help for a command
/? shortcuts Help for keyboard shortcuts
Use """ to begin a multi-line message.
>>> /show info
Model
architecture llama
parameters 3.2B
context length 131072
embedding length 3072
quantization Q4_K_M
Capabilities
completion
tools
Parameters
stop "<|start_header_id|>"
stop "<|end_header_id|>"
stop "<|eot_id|>"
License
LLAMA 3.2 COMMUNITY LICENSE AGREEMENT
Llama 3.2 Version Release Date: September 25, 2024
Info über den Server mit den aktiven Variablen
pp@MacStudio2025 ~ % ollama serve
2025/04/29 21:57:05 routes.go:1232:
INFO server config env="map[
HTTPS_PROXY:
HTTP_PROXY: NO_PROXY:
OLLAMA_CONTEXT_LENGTH:2048
OLLAMA_DEBUG:false
OLLAMA_FLASH_ATTENTION:false
OLLAMA_GPU_OVERHEAD:0
OLLAMA_HOST:http://0.0.0.0:11434
OLLAMA_KEEP_ALIVE:5m0s
OLLAMA_KV_CACHE_TYPE:
OLLAMA_LLM_LIBRARY:
OLLAMA_LOAD_TIMEOUT:5m0s
OLLAMA_MAX_LOADED_MODELS:0
OLLAMA_MAX_QUEUE:512
OLLAMA_MODELS:/Users/pp/.ollama/models
OLLAMA_MULTIUSER_CACHE:false
OLLAMA_NEW_ENGINE:false
OLLAMA_NOHISTORY:false
OLLAMA_NOPRUNE:false
OLLAMA_NUM_PARALLEL:0
OLLAMA_ORIGINS:[http://localhost
https://localhost
http://localhost:*
https://localhost:*
http://127.0.0.1
https://127.0.0.1
http://127.0.0.1:*
https://127.0.0.1:*
http://0.0.0.0 https://0.0.0.0
http://0.0.0.0:*
https://0.0.0.0:*
app://*
file://*
tauri://*
vscode-webview://*
vscode-file://*]
OLLAMA_SCHED_SPREAD:false
http_proxy:
https_proxy: no_proxy:]"
Test, ob der Server erreichbar ist:
pp@MacBookPro2023 ~ % curl http://192.168.X.XX:11434/
Ollama is running