What this setup is good at
- Inline autocomplete, all day, offline, free
- Single-function work: regex, docstrings, boilerplate
- "Explain this error", shell one-liners, commit messages
- Rubber-ducking on a plane or when the wifi dies
- Anything you don't want leaving the machine
What it will not do
- Autonomous multi-file agent work — 16 GB is the floor for that
- Large-repo reasoning; you have 8K of context, not 200K
- Gnarly cross-file debugging
- Replace a cloud model for hard problems
- Run at the same time as OBS
Install Ollama
Ollama is the runtime. It manages downloads, loads weights onto the GPU, and exposes an OpenAI-compatible HTTP endpoint on port 11434 that every editor extension already knows how to talk to.
Grab OllamaSetup.exe from ollama.com/download and run it. It installs per-user, no admin needed, and starts a background service with a tray icon. Then confirm it's alive:
# PowerShell
ollama --version
curl http://localhost:11434
The second command should return Ollama is running. If it doesn't, open the tray icon and start it manually.
OLLAMA_MODELS to something like D:\ollama\models before you pull anything. Windows key → "environment variables" → Environment Variables → New under User variables. Quit Ollama from the tray and reopen it for the change to take.
Confirm the GPU is actually visible
The G15 is a hybrid-graphics laptop — Intel or AMD integrated plus the NVIDIA card. Everything downstream depends on Ollama finding the 3050 and not quietly falling back to CPU.
nvidia-smi
You want to see the RTX 3050 listed, a driver version, and a memory column reading roughly 6144MiB. Note the number already in use with nothing running — that's your Windows desktop tax, usually 400–700 MB, and you never get it back.
nvidia-smi isn't found, add C:\Windows\System32 to PATH or update your NVIDIA driver through GeForce Experience. If the card is listed but shows 0 MB used and Ollama still runs slowly, check Windows Graphics Settings and set Ollama to High performance so it isn't pinned to the integrated GPU.
Pull the two models
Two, not ten. A small chat model and a smaller completion model, chosen so both fit in VRAM simultaneously. Different jobs, different weight classes.
# chat, explanations, single-function work — ~2.5 GB
ollama pull qwen3.5:4b
# fill-in-middle autocomplete — ~1 GB
ollama pull qwen2.5-coder:1.5b-base
-base suffix is deliberate. Autocomplete uses fill-in-middle, which needs the base model's FIM tokens. Instruct-tuned variants will answer your code as if it were a question — you'll get "Sure! Here's a function that…" pasted into your editor. If you only ever remember one detail from this page, make it this one.
Optional, if you later want local embeddings for a document index:
ollama pull nomic-embed-text # ~275 MB
Fix the context window
This is the step that decides whether your setup works. Ollama ships a small default context — a couple of thousand tokens. Any real task overflows it, and instead of erroring, the model silently forgets the beginning of the conversation and starts inventing.
Create a file named exactly Modelfile — no extension:
FROM qwen3.5:4b
PARAMETER num_ctx 8192
Then build the variant and point everything at it from here on:
ollama create qwen3.5:4b-8k -f Modelfile
ollama list
Modelfile.txt and ollama create then can't find the file. Create it from PowerShell with New-Item Modelfile, or save it from VS Code with the file type set to Plain Text and no extension.
Why 8192 and not 32768: context lives in the KV cache, which sits in VRAM alongside the weights. On this card 8K is generous, 16K is possible if you close everything, and 32K will spill to system RAM and drop you to single-digit tokens per second. Drag the slider at the top of this page to see it happen.
Verify full GPU offload
A model that's 90% on the GPU and 10% on the CPU runs at roughly CPU speed. Partial offload is the single most common reason a local setup feels broken, and Ollama won't warn you about it.
Send one prompt, then immediately check what's resident:
ollama run qwen3.5:4b-8k "say hi"
ollama ps
Read the PROCESSOR column. It must say 100% GPU. Anything like 34%/66% CPU/GPU means you've overcommitted — lower num_ctx, close a VRAM consumer, or drop to a smaller model.
For the full picture, the server log records exactly how many layers made it onto the card:
Get-Content "$env:LOCALAPPDATA\Ollama\server.log" -Tail 60 | Select-String "offload"
Tune the runtime for a small card
Three environment variables do most of the work. Set them the same way you set OLLAMA_MODELS, then restart Ollama from the tray.
| Variable | Set to | Why |
|---|---|---|
OLLAMA_MAX_LOADED_MODELS | 2 | Lets the chat and autocomplete models stay resident together. Higher than 2 and they'll evict each other on 6 GB. |
OLLAMA_KEEP_ALIVE | 10m | How long an idle model holds VRAM. The default 5m makes you wait through a reload constantly; forever starves everything else. |
OLLAMA_FLASH_ATTENTION | 1 | Meaningfully smaller KV cache. On a 6 GB card this is close to free context. |
OLLAMA_MODELS | D:\ollama\models | Keeps multi-gigabyte downloads off the system drive. |
Wire it into VS Code
Twinny, not Cline. Cline is an autonomous agent built to plan across many files and run terminal commands — it needs far more context than this card can hold and will thrash. Twinny is a lighter extension that does the two things a 3050 does well: inline completion and side-panel chat.
Install Twinny from the VS Code marketplace, open its providers panel, and configure two entries. Field labels shift between versions, so match on meaning rather than exact wording:
Fill-in-middle provider
- Provider
- Ollama
- Hostname
localhost· port11434- Model
qwen2.5-coder:1.5b-base- FIM template
codeqwen— wrong template here is why completions come back as prose
Chat provider
- Provider
- Ollama
- Hostname
localhost· port11434- Model
qwen3.5:4b-8k— the variant from step 04, not the base tag
Anything else speaking the OpenAI API works the same way: base URL http://localhost:11434/v1, any non-empty string as the API key.
Reaching the internet when you need it
Keep search as a tool the model calls, not something baked into the setup. Everything stays offline until you explicitly ask for a lookup.
The zero-cost path is Open WebUI with a self-hosted SearXNG — a browser chat UI over your local Ollama, with a search toggle and no API keys. Run both with Docker Desktop:
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway \
-v open-webui:/app/backend/data --name open-webui \
ghcr.io/open-webui/open-webui:main
Open localhost:3000, point it at http://host.docker.internal:11434, then add a SearXNG instance under Settings → Web Search.
Keeping it fast
On a 24 GB card VRAM hygiene is optional. On 6 GB it's the difference between 30 tokens per second and 3.
- Browsers reserve VRAM per window. Hardware acceleration in Chrome or Edge can hold several hundred megabytes. Closing tabs doesn't always release it — close the window.
- Don't run inference and OBS together. The NVENC encoder wants VRAM and it wants it consistently. Given the broadcast work, treat these as mutually exclusive modes rather than trying to tune around it.
- Plug in and set the Windows power mode to Best performance. On battery the 3050 clocks down hard and you'll blame the model.
- Expect fan noise. Sustained generation pins the GPU at 100%. This is normal, not a fault.
- Unload on demand when you need the card back:
ollama stop qwen3.5:4b-8k.
When it misbehaves
| Symptom | Actual cause | Fix |
|---|---|---|
| Generation crawls at 2–4 tokens/sec | Partial CPU offload | ollama ps — if it isn't 100% GPU, cut num_ctx to 4096 or close a VRAM consumer |
| Forgets instructions mid-task, invents file contents | Context truncation | You're at the ceiling. Shorten the task rather than raising context — the card can't give you more |
| Autocomplete returns chatty prose | Instruct model, or wrong FIM template | Use the -base tag and set the template to codeqwen |
ollama create can't find the Modelfile |
Notepad appended .txt |
Show file extensions in Explorer and rename, or recreate with New-Item Modelfile |
| VS Code can't reach the model | Service stopped, or wrong host | curl http://localhost:11434. Use 127.0.0.1 if localhost resolves to IPv6 |
| "requires more system memory" | Model too large for card + RAM | Drop a weight class. A 9B will not fit here at usable speed |
| First prompt after idle takes 20 seconds | Model was evicted, reloading from disk | Raise OLLAMA_KEEP_ALIVE, and keep models on an SSD |
| C: drive filling up | Default model path | Set OLLAMA_MODELS, then move the existing ~/.ollama/models folder across |
Command reference
--- daily ---
ollama ps # what's resident, and on what processor
ollama list # installed models and sizes
ollama run qwen3.5:4b-8k # interactive chat in the terminal
ollama stop qwen3.5:4b-8k # free the VRAM now
--- managing models ---
ollama pull <model> # download
ollama rm <model> # delete and reclaim disk
ollama create <name> -f Modelfile # build a tuned variant
ollama show <model> # context length, quant, licence
--- diagnostics ---
nvidia-smi # VRAM total and in use
nvidia-smi -l 2 # live, refreshing every 2s
curl http://localhost:11434 # is the server up
curl http://localhost:11434/api/tags # models over HTTP
When you outgrow it
Nothing above makes a 3050 into an agentic coding machine, and no amount of configuration will. The jump that actually changes what's possible is 24 GB of VRAM — a used RTX 3090 desktop, roughly €600–800 once, which puts a 27B-class model fully on the card with 32K of context and makes autonomous multi-file agents viable.
Until then the honest split is: local models for autocomplete, offline work, and anything you don't want leaving the laptop; cloud models for the hard problems. Most people on this hardware land there, and it works better than trying to force one tool to do both jobs.