Ollama, açık ağırlıklı (open-weight) dil modellerini (Qwen, Gemma, Llama vb.) kendi dizüstü bilgisayarınızda, iş istasyonunuzda ya da sunucunuzda çalıştırır ve yerel bir HTTP API üzerinden sunar. Bu rehberde bellek hesabını, model ve niceleme (quantization) seçimini, API'nin koddan kullanımını ve tek bir sunucunun ekiple güvenli biçimde paylaşılmasını ele alıyoruz. Komutlar ve varsayılan değerler Ekim 2026 itibarıyla Ollama v0.40.11 ve docs.ollama.com'a göredir; Ollama hızlı değiştiği için bir fark görürseniz resmî dokümantasyonu esas alın.
Ollama nedir, yerel çalıştırmak ne zaman mantıklıdır?
Ollama, modelleri kendi kütüphanesinden indirip 11434 numaralı porttan sunan, MIT lisanslı açık kaynak bir çalışma ortamıdır (runtime); komut satırı aracı (CLI) ve masaüstü uygulamasıyla birlikte gelir. GGML/llama.cpp ekosistemi üzerine kuruludur ve kütüphanedeki modellerin çoğu nicelenmiş hâldedir: Llama 3.1 8B'nin varsayılan indirmesi 16 GB yerine 4,9 GB'tır.- Gizlilik ve KVKK: Veriler sizin donanımınızda kalır. 6698 sayılı KVKK'nın 9. maddesi (2024'te 7499 sayılı Kanun ile değiştirildi) kişisel verilerin yurt dışına aktarılmasını düzenler; yurt dışındaki bir bulut API'sine veri göndermek tam da bu soruyu doğurur. Yerel çıkarım (inference) bu aktarımı ortadan kaldırır, ancak 12. maddedeki veri güvenliği tedbirleri gibi diğer yükümlülükler sürer. Güncel metni mevzuat.gov.tr'den kontrol edin ve hukuk danışmanınızla doğrulayın.
- Çevrimdışı çalışma: İndirilmiş bir model internet istemez; fabrika, laboratuvar ve kapalı ağlar için uygundur.
- Öngörülebilir maliyet: Token başına ücret yerine donanım ve elektrik ödersiniz; destek kayıtlarını sınıflandırma, log özetleme ya da embedding üretimi gibi toplu işlerde bu fark büyür.
- Kontrol: Sağlayıcı kaynaklı hız sınırı (rate limit) yoktur ve model siz değiştirmedikçe değişmez.
Donanım hesabı: Bir model için ne kadar VRAM gerekir?
Bellek ihtiyacı üç parçadan oluşur:- Ağırlıklar: parametre sayısı × ağırlık başına bayt; Q4_K_M için yaklaşık 0,6, Q8_0 için 1,06, FP16 için 2 bayt.
- KV önbelleği (KV cache): bağlamdaki her token için 2 × katman × KV başlığı × başlık boyutu × 2 bayt (varsayılan f16); toplam, paralel istek sayısıyla çarpılır.
- Ek yük: çalışma tamponları ve GPU sürücüsü için kabaca 1–2 GB.
| Model | Ağırlıklar | KV önbelleği 4K / 32K | Hedef bellek |
|---|---|---|---|
| 8B Q4_K_M | 4,9 GB | 0,5 / 4 GB | 4K için 8 GB VRAM, 32K için 12 GB |
| 8B Q8_0 | 8,5 GB | 0,5 / 4 GB | 4K için 12 GB, 32K için 16 GB |
| 70B Q4_K_M | 43 GB | 1,25 / 10 GB | 4K için 48 GB, 32K için 56 GB ve üzeri |
| 70B Q8_0 | 75 GB | 1,25 / 10 GB | 4K için 80 GB, 32K için yaklaşık 90 GB |
- NVIDIA veya AMD GPU: Model tamamen VRAM'e sığdığında en hızlı seçenektir. NVIDIA için hesaplama yeteneği (compute capability) 5.0 ve üzeri ile 550+ sürücü gerekir (5.0–6.2 arasındaki kartlarda 570+). Desteklenen Radeon kartlar ROCm v7 sürücüsü ister; Vulkan desteği Windows ve Linux'ta daha fazla GPU'yu kapsar.
- Apple Silicon: Metal birleşik belleği (unified memory) kullanır; 64 GB'lık bir Mac, tek bir tüketici ekran kartına sığmayacak büyüklükteki modelleri barındırabilir. macOS bu belleğin GPU'ya ayrılabilecek kısmını sınırlar, bu yüzden pay bırakın. Intel işlemcili Mac'ler yalnızca CPU ile çalışır.
- Yalnızca CPU: Hızı bellek bant genişliği belirler; küçük modeller (kabaca 1–4B), embedding ve beklemenin sorun olmadığı toplu işler için uygundur.
- Kısmi GPU aktarımı (partial offload): Model sığmazsa Ollama kalan katmanları CPU'da çalıştırır ve üretim belirgin biçimde yavaşlar; ollama ps bu durumda 48%/52% CPU/GPU gibi bir dağılım gösterir.
Varsayılan bağlam uzunluğu (context length) da toplam VRAM'e göre belirlenir: 24 GiB altında 4K, 24–48 GiB arasında 32K, daha fazlasında 256K. Değer, modelin eğitildiği bağlam penceresini aşmaz (Llama 3.1'de 128K); yine de 70B bir Llama'da 128K bağlam tek başına yaklaşık 40 GB KV önbelleği demektir. Dokümantasyon ajanlar, kodlama araçları ve web araması için en az 64.000 token öneriyor; sunucularda değeri açıkça ayarlayın ve ollama ps çıktısındaki CONTEXT sütununu kontrol edin. Dokümantasyona göre OLLAMA_KV_CACHE_TYPE=q8_0, kaliteyi çok az etkileyerek önbelleği kabaca yarıya indirir. Bunun için Flash Attention gerekir; Ollama, donanım desteklediğinde onu kendiliğinden açar.
macOS, Windows, Linux ve Docker'da Ollama kurulumu
macOS 14 ve üzerinde .dmg dosyasındaki Ollama'yı Applications klasörüne sürükleyin. Windows 10 22H2 ve üzerinde OllamaSetup.exe'yi çalıştırın; yönetici yetkisi gerekmez. Linux'ta:
Bash:
curl -fsSL https://ollama.com/install.sh | sh
ollama -v
journalctl -u ollama --no-pager --follow --pager-end
Bash:
docker run -d --gpus=all -v ollama:/root/.ollama \
-p 127.0.0.1:11434:11434 --name ollama ollama/ollama
Modeller macOS'ta ~/.ollama/models, Linux servisinde /usr/share/ollama/.ollama/models, Windows'ta C:\Users\%username%\.ollama\models altında durur. Başka bir diske taşımak için OLLAMA_MODELS değişkenini kullanın. Linux'ta sudo systemctl edit ollama ile Service bölümüne Environment="OLLAMA_MODELS=/data/ollama" satırını ekleyin, sudo chown -R ollama
Günlük komutlar ve niceleme seçimi
Bash:
ollama pull qwen3:8b # indir
ollama run qwen3:8b # sohbet; /bye ile çıkılır, /set parameter num_ctx 16384 bağlamı değiştirir
ollama ls # kurulu modeller
ollama ps # yüklü modeller, CPU/GPU dağılımı, bağlam, boşaltma zamanı
ollama show qwen3:8b # mimari, parametre sayısı, bağlam uzunluğu, niceleme
ollama stop qwen3:8b # hemen bellekten çıkar
ollama rm qwen3:8b # sil
| Niceleme | Llama 3.1 8B boyutu | Ne zaman seçilir? |
|---|---|---|
| Q4_K_M | 4,9 GB | Varsayılan; aynı VRAM'e en büyük modeli sığdırır |
| Q5_K_M, Q6_K | 5,7 / 6,6 GB | Bellekte pay varsa; özgün modele daha yakın çıktı |
| Q8_0 | 8,5 GB | Kaliteye duyarlı işler; testlerinizde Q4 hata yapıyorsa |
| FP16 | 16 GB | Nicelemenin kaliteyi ne kadar düşürdüğünü ölçmek için referans |
Türkçe kalitesini kendi istemlerinizle test edin
Model kartları birbirinden farklıdır: Llama 3.1'in kartı desteklenen sekiz dili sayar, Türkçe bunların arasında değildir ve kart diğer dillerde kullanımı kapsam dışı (out-of-scope) olarak listeler. Qwen3'ün kartı 100'den fazla dil, Gemma 4'ün kartı ise ek eğitim gerektirmeden 35'ten fazla dil desteği belirtir. Gerçek işinizden 20–30 istem (prompt) toplayın: destek e-postaları, Türkçe hata mesajları, KVKK aydınlatma metni taslakları. Her adayı sıcaklık (temperature) 0 ve sabit tohum (seed) ile çalıştırın; ekleri, ı, İ, ğ ve ş harflerini, terminolojiyi ve uydurulmuş bilgileri puanlayın:
Python:
import ollama
istemler = open("tr_istemler.txt", encoding="utf-8").read().split("\n---\n")
for m in ["qwen3:8b", "qwen3:8b-q8_0", "gemma4:e4b"]:
for p in istemler:
r = ollama.chat(model=m, messages=[{"role": "user", "content": p}],
options={"temperature": 0, "seed": 42}, think=False)
print(m, r.prompt_eval_count, r.message.content, sep="\n", end="\n\n")
Modelfile ile modeli özelleştirme
Code:
FROM qwen3:8b
PARAMETER num_ctx 16384
PARAMETER temperature 0.3
SYSTEM """Şirket içi BT asistanısın. Kullanıcının dilinde kısa yanıt ver; emin olmadığında bunu açıkça söyle."""
En uzun gerçek girdinizi ve yanıtı alacak en küçük bağlamı seçin: 4K yerine 32K, 8B bir Llama'nın önbelleğini 0,5 GB'tan 4 GB'a çıkarır ve bu değer OLLAMA_NUM_PARALLEL ile çarpılır. Fazla küçük bağlam daha kötüdür: Sohbet pencereyi aştığında Ollama, sistem mesajlarını ve son mesajı her zaman tutarak kalan kısım sığana kadar en eski mesajları hata vermeden atar. Model, konuşmanın başını unutmuş gibi görünür.
Ollama API'sini koddan kullanmak
Sunucu http://localhost:11434 adresinde API anahtarı istemeden dinler. Başlıca uç noktalar (endpoint) POST /api/chat, /api/generate ve /api/embed ile GET /api/tags, /api/ps ve /api/version'dır.
Bash:
curl http://localhost:11434/api/chat -d '{
"model": "qwen3:8b",
"messages": [{"role": "user", "content": "RAID 1 ile RAID 5 farkını iki cümlede açıkla."}],
"think": false,
"stream": false,
"options": {"temperature": 0.2, "num_ctx": 8192}
}'
OpenAI uyumlu uç nokta
Mevcut OpenAI SDK kodunuz için yeni bir base URL yeterlidir. SDK bir anahtar ister, Ollama bu anahtarı yok sayar:
Python:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1/", api_key="ollama")
r = client.chat.completions.create(
model="qwen3:8b",
messages=[{"role": "user", "content": "Atölyede Raspberry Pi için üç kullanım alanı öner."}],
)
print(r.choices[0].message.content)
Küçük bir RAG için embedding
/api/embed tek bir metin ya da liste alır ve L2 normuyla birim uzunluğa getirilmiş vektörler döndürür; bu yüzden nokta çarpımı kosinüs benzerliğine eşittir. Dizinleme ve sorgu için aynı modeli kullanın; embeddinggemma, bge-m3 ve qwen3-embedding gibi çok dilli seçenekleri kendi Türkçe sorgularınızla deneyin:
Python:
import ollama
belgeler = ["Yedekler her gece 02:00'de alınır ve 30 gün saklanır.",
"VPN erişimi için BT müdürünün onayladığı bir kayıt gerekir."]
vektorler = ollama.embed(model="embeddinggemma", input=belgeler)["embeddings"]
soru = "Yedekler kaç gün saklanıyor?"
q = ollama.embed(model="embeddinggemma", input=soru)["embeddings"][0]
skorlar = [sum(a * b for a, b in zip(q, v)) for v in vektorler]
baglam = belgeler[skorlar.index(max(skorlar))]
r = ollama.chat(model="qwen3:8b", think=False, messages=[
{"role": "system", "content": "Yalnızca bağlamdaki bilgiyle yanıt ver; bilgi yoksa bilmediğini söyle."},
{"role": "user", "content": f"Bağlam: {baglam}\n\nSoru: {soru}"}])
print(r.message.content)
Ollama'yı ekibe güvenli şekilde açmak
Yerel API'de kimlik doğrulama yoktur: 11434 portuna ulaşabilen herkes model çalıştırabilir, disk dolana kadar yeni model indirebilir ya da /api/delete ile model silebilir. Ollama varsayılan olarak yalnızca 127.0.0.1'de dinler; bunu koruyun ve erişimi bilinçli olarak açın:- SSH tüneli: ssh -L 11434:localhost:11434 kullanici@gpu-sunucu; bir iki geliştirici için yeterlidir.
- VPN: Ollama tüm arayüzlerde dinler, güvenlik duvarı yalnızca VPN alt ağına izin verir.
- Ters vekil sunucu (reverse proxy): Ollama 127.0.0.1'de kalır; Nginx ya da Caddy TLS ve kimlik doğrulama ekler.
INI:
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_CONTEXT_LENGTH=16384"
Environment="OLLAMA_NUM_PARALLEL=2"
Environment="OLLAMA_KEEP_ALIVE=30m"
Environment="OLLAMA_KV_CACHE_TYPE=q8_0"
Vekil sunucu yolu için aşağıdaki Nginx taslağı Authorization başlığındaki bearer token'ı denetler; OpenAI SDK'ları api_key değerini zaten bu başlıkla gönderir. Ollama loopback adresinde dinlerken yerel olmayan Host başlıklarına 403 döndürdüğü için Host başlığı yeniden yazılır:
Code:
map $http_authorization $llm_ok { # http bağlamında, örneğin conf.d altındaki bir dosyada
default 0;
"Bearer DEGISTIRIN-uzun-rastgele-token" 1;
}
server {
listen 443 ssl;
server_name llm.example.com;
ssl_certificate /etc/letsencrypt/live/llm.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/llm.example.com/privkey.pem;
location / {
if ($llm_ok = 0) { return 401; }
proxy_pass http://127.0.0.1:11434;
proxy_set_header Host localhost:11434;
proxy_buffering off; # akan tokenları bekletmeden ilet
proxy_read_timeout 600s; # model yükleme ve uzun yanıtlar için
}
}
Ekip için sohbet arayüzü: Open WebUI
Open WebUI, tarayıcıdan kullanılan bir sohbet arayüzüdür; kullanıcı hesapları, sohbet geçmişi ve belge yükleme sunar. Host ağı (host networking), konteynerin yalnızca 127.0.0.1'de dinleyen Ollama'ya ulaşmasını sağlar:
Bash:
# gizli anahtarı bir kez üretip saklayın: openssl rand -hex 32
docker run -d --network=host -v open-webui:/app/backend/data \
-e OLLAMA_BASE_URL=http://127.0.0.1:11434 -e WEBUI_SECRET_KEY=degistirin \
--name open-webui --restart always ghcr.io/open-webui/open-webui:main
Eşzamanlılık ve bellek ayarları
| Değişken | Varsayılan | Etkisi |
|---|---|---|
| OLLAMA_NUM_PARALLEL | 1 | Model başına paralel istek; her yuva (slot) kendi bağlamı kadar KV önbelleği ister |
| OLLAMA_MAX_LOADED_MODELS | GPU başına 3, CPU'da 3 | Sığdıkları sürece aynı anda bellekte tutulan model sayısı |
| OLLAMA_MAX_QUEUE | 512 | Sunucu 503 döndürmeden önce kuyrukta bekleyebilecek istek sayısı |
| OLLAMA_KEEP_ALIVE | 5m | Boşta kalan modelin bellekten çıkarılma süresi; -1 sürekli tutar, 0 hemen boşaltır; istekteki keep_alive bu değeri geçersiz kılar |
Ollama sorun giderme
İlk adım günlükleri okumaktır: macOS'ta ~/.ollama/logs/server.log, Linux'ta journalctl -u ollama, Windows'ta %LOCALAPPDATA%\Ollama\server.log, konteynerde docker logs ollama. OLLAMA_DEBUG=1 daha fazla ayrıntı verir.| Belirti | Olası neden | Çözüm |
|---|---|---|
| ollama ps 100% CPU gösteriyor | Sürücü yok ya da eski, konteynerin GPU erişimi yok, Linux'ta uyku modundan sonra GPU kayboldu | nvidia-smi çıktısını kontrol edin; Docker'da docker run --gpus all ubuntu nvidia-smi ile deneyin; uyku sonrasında sudo rmmod nvidia_uvm && sudo modprobe nvidia_uvm çalıştırın; AMD için ROCm v7 sürücüsü gerekir |
| Model yüklenmiyor, günlükte "out of memory" var | Ağırlıklar ve KV önbelleği boş VRAM'i aşıyor ya da başka modeller yüklü | Daha küçük niceleme ya da model, daha düşük num_ctx, OLLAMA_KV_CACHE_TYPE=q8_0; diğer modelleri ollama stop ile boşaltın |
| Çıktı çok yavaş | CPU/GPU bölünmesi, gereğinden büyük bağlam, swap kullanımı | ollama ps'te 100% GPU hedefleyin, bağlamı düşürün, ollama run --verbose ile ölçün |
| bind: address already in use | Uygulama ya da servis zaten 11434'te çalışıyor veya portu başka bir program tutuyor | Çalışan sunucuyu kullanın; portu tutan süreci ss -ltnp, lsof -i :11434 ya da netstat -ano ile bulun; gerekirse OLLAMA_HOST=127.0.0.1:11435 kullanın |
| Vekil sunucu üzerinden 403 Forbidden | Loopback adresinde dinlerken yapılan Host başlığı denetimi | proxy_set_header Host localhost:11434 |
| Türkçe karakterler bozuk görünüyor | Terminal ya da istek gövdesi UTF-8 değil | Linux: locale çıktısı C.UTF-8 ya da tr_TR.UTF-8 gibi bir UTF-8 yerel ayarı göstermeli; Windows: Windows Terminal ya da chcp 65001; PowerShell: -ContentType değerine charset=utf-8 ekleyin; curl: gövdeyi UTF-8 kaydedilmiş bir dosyadan -d @govde.json ile gönderin |
| Modelin ticari kullanımından emin değilsiniz | Her modelin kendi lisansı var | ollama show --license; Qwen3 ve Gemma 4 kartları Apache 2.0 belirtir, Llama 3.1 ise kabul edilebilir kullanım politikasıyla birlikte Llama 3.1 Community License kullanır |
Ollama, llama.cpp server, LM Studio ve vLLM karşılaştırması
| Araç | En uygun kullanım | Modeller | Sunum notları |
|---|---|---|---|
| Ollama | Kararlı bir API ile indir-çalıştır kolaylığı isteyen geliştiriciler ve küçük ekipler | Ollama kütüphanesi, GGUF ve Safetensors içe aktarma, hf.co GGUF'ları | Kendi API'si, OpenAI ve Anthropic uyumlu API'ler; yerleşik kimlik doğrulama yok |
| llama.cpp (llama-server) | Her parametre üzerinde tam kontrol, az bağımlılık, uç cihazlar | GGUF | OpenAI uyumlu API ve web arayüzü; --api-key ve TLS seçenekleri |
| LM Studio | Modelleri grafik arayüzle gezip karşılaştırmak isteyen masaüstü kullanıcıları | llama.cpp ile GGUF, Apple Silicon'da MLX | OpenAI benzeri yerel sunucu ve lms CLI; uygulama kapalı kaynak (CLI ve SDK'lar MIT lisanslı), Temmuz 2025'ten beri evde ve işte ücretsiz |
| vLLM | Veri merkezi GPU'larında çok sayıda eşzamanlı kullanıcıya üretim ortamı sunumu | Hugging Face modelleri | --api-key destekli OpenAI uyumlu sunucu; öncelikle Linux, daha fazla kurulum ve ayar ister |
Sık sorulan sorular
Ollama ticari kullanımda ücretsiz mi?Ollama'nın kendisi MIT lisanslıdır, ancak her modelin ayrı bir lisansı vardır; bir ürüne koymadan önce ollama show --license çıktısını okuyun.
Ollama GPU olmadan çalışır mı?
Evet. Küçük modeller ve embedding işleri modern bir CPU'da kullanılabilir; büyük modeller de çalışır ama yavaştır.
Türkçe için en iyi model hangisi?
Herkese uyan bir cevap yok. Belleğinize sığan iki üç modeli seçin, kartlarındaki dil desteğine bakın ve kendi istemlerinizle karşılaştırın.
Ollama istemlerimi bir yere gönderiyor mu?
Ollama'nın SSS sayfasına göre yerel modeller yerelde çalışır ve Ollama istemlerinizi görmez. Bulut modelleri ise Ollama'nın sunucularında işlenir; yalnızca yerel işlemeye izin veriliyorsa OLLAMA_NO_CLOUD=1 ayarlayın.
Modelleri kaybetmeden nasıl güncellerim?
Linux'ta kurulum betiğini yeniden çalıştırın; macOS ve Windows'ta uygulama güncellemesini onaylayın. İndirilen modeller yerinde kalır.
Sonuç ve sonraki adımlar
Modeli ağırlık + KV önbelleği + ek yük formülüyle boyutlandırın, tamamen VRAM'e sığan bir etiket indirin ve ollama ps ile modelin %100 GPU'da, beklediğiniz bağlamla çalıştığını doğrulayın. Ardından gerçek işlerden bir Türkçe test seti hazırlayın, bağlamı ve keep-alive süresini Modelfile ya da servis ayarlarında sabitleyin, sunucuyu yalnızca VPN ya da kimlik doğrulamalı bir TLS vekil sunucusu üzerinden paylaşın. Sonraki adım, kendi belgelerinizi embedding ile bağlamak ve yukarıda bağlantısı verilen RAG rehberini uygulamak. GPU donanımını kendiniz işletmek istemiyorsanız AIOR'un yapay zeka ve GPU sunucuları da bir seçenektir. Kendi kurulumunuzla ilgili soruları bu konuya yazabilirsiniz.Ollama runs open-weight language models such as Qwen, Gemma and Llama on your own laptop, workstation or server and serves them through a local HTTP API. This guide covers memory sizing, model and quantization choice, the API, and sharing one server safely with a team. Commands and defaults follow docs.ollama.com as of Ollama v0.40.11 (October 2026); Ollama moves fast, so the docs win when something differs.
What Ollama is and when running locally makes sense
Ollama is an MIT-licensed open-source runtime that downloads models from its library and serves them on port 11434; it ships with a CLI and a desktop app. It builds on the GGML/llama.cpp ecosystem, and library models are mostly quantized: the default Llama 3.1 8B download is 4.9 GB instead of 16 GB.- Privacy and KVKK: data stays on your hardware. Article 9 of KVKK, Türkiye's personal data protection law (No. 6698), as amended by Law No. 7499 in 2024, governs transfers of personal data abroad, which is exactly the question a foreign hosted API raises. Local inference avoids that transfer, but duties such as the Article 12 security measures remain; check the current text on mevzuat.gov.tr with your legal adviser.
- Offline work: a pulled model needs no internet, which suits factories, labs and isolated networks.
- Predictable cost: hardware and power instead of per-token fees, a difference that grows with bulk jobs such as ticket classification, log summaries or embeddings.
- Control: no provider rate limits, and the model changes only when you change it.
Hardware sizing: how much VRAM do you need?
Memory has three parts:- Weights: parameters × bytes per weight, about 0.6 for Q4_K_M, 1.06 for Q8_0 and 2 for FP16.
- KV cache: 2 × layers × KV heads × head dimension × 2 bytes (default f16) per token of context, times the number of parallel requests.
- Overhead: buffers and the GPU driver, roughly 1–2 GB.
| Model | Weights | KV cache at 4K / 32K | Plan for |
|---|---|---|---|
| 8B Q4_K_M | 4.9 GB | 0.5 / 4 GB | 8 GB VRAM at 4K, 12 GB at 32K |
| 8B Q8_0 | 8.5 GB | 0.5 / 4 GB | 12 GB at 4K, 16 GB at 32K |
| 70B Q4_K_M | 43 GB | 1.25 / 10 GB | 48 GB at 4K, 56 GB or more at 32K |
| 70B Q8_0 | 75 GB | 1.25 / 10 GB | 80 GB at 4K, about 90 GB at 32K |
- NVIDIA or AMD GPU: fastest when everything fits. NVIDIA needs compute capability 5.0+ and driver 550+ (570+ for compute capability 5.0–6.2); Radeon cards need the ROCm v7 driver, and Vulkan covers more GPUs on Windows and Linux.
- Apple Silicon: Metal uses unified memory, so a 64 GB Mac can hold models too large for any single consumer graphics card. macOS caps the GPU's share of that memory, so leave headroom. Intel Macs are CPU-only.
- CPU only: bound by memory bandwidth; fine for small models (roughly 1–4B), embeddings and batch jobs.
- Partial offload: if a model does not fit, Ollama runs the remaining layers on the CPU and output slows sharply; ollama ps shows a split such as 48%/52% CPU/GPU.
The default context depends on total VRAM: 4K below 24 GiB, 32K from 24 to 48 GiB and 256K above. It never exceeds the model's trained window (128K for Llama 3.1), but 128K of context alone means about 40 GB of KV cache for a 70B Llama. The docs recommend at least 64,000 tokens for agents, coding tools and web search, so set the value explicitly on servers and check the CONTEXT column of ollama ps. OLLAMA_KV_CACHE_TYPE=q8_0 roughly halves the cache with very little quality loss, according to the docs; it needs Flash Attention, which Ollama enables where the hardware supports it.
Installing Ollama on macOS, Windows, Linux and Docker
On macOS 14 or newer, drag Ollama from the .dmg into Applications. On Windows 10 22H2 or newer, run OllamaSetup.exe, which needs no admin rights. On Linux:
Bash:
curl -fsSL https://ollama.com/install.sh | sh
ollama -v
journalctl -u ollama --no-pager --follow --pager-end
Bash:
docker run -d --gpus=all -v ollama:/root/.ollama \
-p 127.0.0.1:11434:11434 --name ollama ollama/ollama
Models live in ~/.ollama/models on macOS, /usr/share/ollama/.ollama/models for the Linux service and C:\Users\%username%\.ollama\models on Windows. To move them, set OLLAMA_MODELS. On Linux, add Environment="OLLAMA_MODELS=/data/ollama" to the Service section with sudo systemctl edit ollama, hand the directory to the service user with sudo chown -R ollama
Everyday commands and choosing a quantization
Bash:
ollama pull qwen3:8b # download
ollama run qwen3:8b # chat; /bye exits, /set parameter num_ctx 16384 changes the context
ollama ls # installed models
ollama ps # loaded models, CPU/GPU split, context, unload time
ollama show qwen3:8b # architecture, parameters, context length, quantization
ollama stop qwen3:8b # unload now
ollama rm qwen3:8b # delete
| Quantization | Llama 3.1 8B size | When to choose it |
|---|---|---|
| Q4_K_M | 4.9 GB | Default; the most model per GB of VRAM |
| Q5_K_M, Q6_K | 5.7 / 6.6 GB | Spare memory, output closer to the original |
| Q8_0 | 8.5 GB | Quality-sensitive work when Q4 makes mistakes in your tests |
| FP16 | 16 GB | Reference runs to measure how much quality quantization costs |
Test Turkish quality on your own prompts
Model cards differ: Llama 3.1's lists eight supported languages, Turkish is not one of them, and the card lists use in other languages as out of scope. Qwen3's card claims more than 100 languages and Gemma 4's 35+ out of the box. Run 20–30 prompts from real work (support emails, Turkish error messages, KVKK notice drafts) at temperature 0 with a fixed seed, and grade suffixes, the letters ı, İ, ğ and ş, terminology and invented facts:
Python:
import ollama
prompts = open("tr_prompts.txt", encoding="utf-8").read().split("\n---\n")
for m in ["qwen3:8b", "qwen3:8b-q8_0", "gemma4:e4b"]:
for p in prompts:
r = ollama.chat(model=m, messages=[{"role": "user", "content": p}],
options={"temperature": 0, "seed": 42}, think=False)
print(m, r.prompt_eval_count, r.message.content, sep="\n", end="\n\n")
Customising a model with a Modelfile
Code:
FROM qwen3:8b
PARAMETER num_ctx 16384
PARAMETER temperature 0.3
SYSTEM """You are the internal IT assistant. Answer briefly, in the user's language, and say so when you are not sure."""
Pick the smallest context that holds your longest real input plus the answer: 32K instead of 4K grows an 8B Llama's cache from 0.5 GB to 4 GB, multiplied by OLLAMA_NUM_PARALLEL. Too small is worse: when a chat overflows the window, Ollama silently drops the oldest messages until the rest fits, always keeping the system messages and the latest one, so the model seems to forget the start of the conversation.
Calling the Ollama API from code
The server listens on http://localhost:11434 without an API key. The main endpoints are POST /api/chat, /api/generate and /api/embed, plus GET /api/tags, /api/ps and /api/version.
Bash:
curl http://localhost:11434/api/chat -d '{
"model": "qwen3:8b",
"messages": [{"role": "user", "content": "Explain RAID 1 vs RAID 5 in two sentences."}],
"think": false,
"stream": false,
"options": {"temperature": 0.2, "num_ctx": 8192}
}'
OpenAI-compatible endpoint
Existing OpenAI SDK code needs only a new base URL. The SDK insists on a key, which Ollama ignores:
Python:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1/", api_key="ollama")
r = client.chat.completions.create(
model="qwen3:8b",
messages=[{"role": "user", "content": "Give three uses for a Raspberry Pi in a workshop."}],
)
print(r.choices[0].message.content)
Embeddings for a small RAG
/api/embed takes a string or a list and returns L2-normalised vectors, so the dot product equals cosine similarity. Use one model for indexing and querying, and test multilingual options such as embeddinggemma, bge-m3 and qwen3-embedding on your own Turkish queries:
Python:
import ollama
docs = ["Backups run nightly at 02:00 and are kept for 30 days.",
"VPN access needs a ticket approved by the IT manager."]
vecs = ollama.embed(model="embeddinggemma", input=docs)["embeddings"]
question = "How long are backups kept?"
q = ollama.embed(model="embeddinggemma", input=question)["embeddings"][0]
scores = [sum(a * b for a, b in zip(q, v)) for v in vecs]
context = docs[scores.index(max(scores))]
r = ollama.chat(model="qwen3:8b", think=False, messages=[
{"role": "system", "content": "Answer only from the context, otherwise say you don't know."},
{"role": "user", "content": f"Context: {context}\n\nQuestion: {question}"}])
print(r.message.content)
Serving Ollama to a team safely
The local API has no authentication: anyone who reaches port 11434 can run models, pull new ones until the disk fills, or delete them through /api/delete. Keep the default 127.0.0.1 binding and open access deliberately:- SSH tunnel: ssh -L 11434:localhost:11434 user@gpu-server, enough for one or two developers.
- VPN: listen on all interfaces and let the firewall admit only the VPN subnet.
- Reverse proxy: Ollama stays on 127.0.0.1 while Nginx or Caddy adds TLS and authentication.
INI:
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_CONTEXT_LENGTH=16384"
Environment="OLLAMA_NUM_PARALLEL=2"
Environment="OLLAMA_KEEP_ALIVE=30m"
Environment="OLLAMA_KV_CACHE_TYPE=q8_0"
For the proxy route, this Nginx sketch checks the bearer token in the Authorization header, which is exactly where OpenAI SDKs send their api_key. On a loopback bind Ollama answers 403 to non-local Host headers, hence the Host rewrite:
Code:
map $http_authorization $llm_ok { # http context, e.g. a conf.d file
default 0;
"Bearer CHANGE-ME-long-random-token" 1;
}
server {
listen 443 ssl;
server_name llm.example.com;
ssl_certificate /etc/letsencrypt/live/llm.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/llm.example.com/privkey.pem;
location / {
if ($llm_ok = 0) { return 401; }
proxy_pass http://127.0.0.1:11434;
proxy_set_header Host localhost:11434;
proxy_buffering off; # pass streamed tokens through at once
proxy_read_timeout 600s; # model loads and long answers
}
}
Open WebUI as the team's chat window
Open WebUI adds a browser chat with user accounts, history and document upload. Host networking lets the container reach an Ollama that listens only on 127.0.0.1:
Bash:
# generate the secret once and keep it: openssl rand -hex 32
docker run -d --network=host -v open-webui:/app/backend/data \
-e OLLAMA_BASE_URL=http://127.0.0.1:11434 -e WEBUI_SECRET_KEY=change-me \
--name open-webui --restart always ghcr.io/open-webui/open-webui:main
Concurrency and memory settings
| Variable | Default | Effect |
|---|---|---|
| OLLAMA_NUM_PARALLEL | 1 | Parallel requests per model; each slot needs its own context's worth of KV cache |
| OLLAMA_MAX_LOADED_MODELS | 3 per GPU, 3 on CPU | Models kept in memory at once, if they fit |
| OLLAMA_MAX_QUEUE | 512 | Waiting requests before the server answers 503 |
| OLLAMA_KEEP_ALIVE | 5m | Idle time before unloading; -1 keeps the model loaded, 0 unloads at once, and a request's keep_alive overrides it |
Troubleshooting Ollama
Start with the log: ~/.ollama/logs/server.log on macOS, journalctl -u ollama on Linux, %LOCALAPPDATA%\Ollama\server.log on Windows, docker logs ollama in a container. OLLAMA_DEBUG=1 adds detail.| Symptom | Likely cause | Fix |
|---|---|---|
| ollama ps shows 100% CPU | Missing or old driver, container without GPU access, GPU lost after a Linux suspend | Check nvidia-smi; in Docker test docker run --gpus all ubuntu nvidia-smi; after suspend run sudo rmmod nvidia_uvm && sudo modprobe nvidia_uvm; AMD needs the ROCm v7 driver |
| Model fails to load, "out of memory" in the log | Weights plus KV cache exceed free VRAM, or other models are loaded | Smaller quantization or model, lower num_ctx, OLLAMA_KV_CACHE_TYPE=q8_0, ollama stop the other models |
| Very slow output | CPU/GPU split, oversized context, swapping | Aim for 100% GPU in ollama ps, lower the context, measure with ollama run --verbose |
| bind: address already in use | The app or service already runs on 11434, or another program holds the port | Use the running server; find the owner with ss -ltnp, lsof -i :11434 or netstat -ano; or set OLLAMA_HOST=127.0.0.1:11435 |
| 403 Forbidden through a proxy | Host header check on a loopback bind | proxy_set_header Host localhost:11434 |
| Turkish characters garbled | Terminal or request body not UTF-8 | Linux: locale should report a UTF-8 locale such as C.UTF-8 or tr_TR.UTF-8; Windows: Windows Terminal or chcp 65001; PowerShell: add charset=utf-8 to -ContentType; curl: -d @body.json from a UTF-8 file |
| Unsure whether a model may be used commercially | Every model has its own licence | ollama show --license; the Qwen3 and Gemma 4 cards state Apache 2.0, Llama 3.1 uses the Llama 3.1 Community License with an acceptable use policy |
Ollama vs llama.cpp server vs LM Studio vs vLLM
| Tool | Best fit | Models | Serving notes |
|---|---|---|---|
| Ollama | Developers and small teams who want pull-and-run with a stable API | Ollama library, GGUF and Safetensors import, hf.co GGUFs | Native, OpenAI- and Anthropic-compatible APIs; no built-in auth |
| llama.cpp (llama-server) | Full control over every flag, few dependencies, edge devices | GGUF | OpenAI-compatible API and web UI; --api-key and TLS options |
| LM Studio | Desktop users who want a GUI to browse and compare models | GGUF via llama.cpp, MLX on Apple Silicon | OpenAI-like local server and lms CLI; closed-source app (the CLI and SDKs are MIT), free for home and work use since July 2025 |
| vLLM | Production serving on data-centre GPUs with many concurrent users | Hugging Face models | OpenAI-compatible server with --api-key; Linux first, more setup and tuning |
FAQ
Is Ollama free for commercial use?Ollama itself is MIT-licensed, but each model has its own licence; read ollama show --license before shipping a product.
Can Ollama run without a GPU?
Yes. Small models and embeddings are usable on a modern CPU; larger models run, but slowly.
Which model is best for Turkish?
There is no universal answer. Shortlist two or three models that fit your memory, check their cards for language support and compare them on your own prompts.
Does Ollama send my prompts anywhere?
Ollama's FAQ says local models run locally and Ollama does not see the prompts. Cloud models are processed on Ollama's servers, so set OLLAMA_NO_CLOUD=1 if only local processing is allowed.
How do I update without losing models?
Re-run the install script on Linux, or accept the app update on macOS and Windows. Downloaded models stay where they are.