cd /news/large-language-models/i-built-an-app-to-run-local-llms-on-… Β· home β€Ί topics β€Ί large-language-models β€Ί article
[ARTICLE Β· art-178118] src=dev.to β†— pub= topic=large-language-models verified=true sentiment=↑ positive

I Built an App to Run Local LLMs on Colab and Vast.ai in One Night

A developer built llm-harness, an app that runs local LLMs such as Qwen on rented Colab and Vast.ai GPUs through a single CLI (up/status/chat/down), automatically selecting vLLM, llama.cpp, or Ollama based on the GPU generation. To stay within Colab's rules against tunnels and remote proxies, the harness drives Google's official Colab CLI via colab exec, passing chat content through environment variables rather than exposing the server. On a Colab Pro T4, Ollama was selected for qwen3:8b, and the developer added OLLAMA_KEEP_ALIVE=-1 to avoid slow first-request model loading.

recommendation

Set OLLAMA_KEEP_ALIVE=-1 so the model stays resident in GPU memory and replies are immediate after the first load; on a T4, qwen3:8b otherwise spent much of its first request loading weights.

more in playbook: Inference and self-hosting
by read5 min views5 publishedNov 29, 2026

I wanted to try local LLMs such as Qwen, but the GPU in my own PC is too weak to run them. Renting a GPU on Colab or Vast.ai works, but redoing the setup every time is tedious.

So, together with Claude, I built a harness (a tool) for running "local LLMs" on rented GPUs in one night, and turned it into an app. It is called llm-harness.

This article is for you if:

The part I struggled with most was working within Colab's rules, so that is the focus of this article.

llm-harness runs one of vLLM, llama.cpp, or Ollama on a Colab or Vast.ai GPU.

I shaped it step by step while asking Claude for changes.

llm-harness up / status / chat / down There are two routes for renting a GPU: Vast.ai and Colab.

Both routes end up usable as an OpenAI-compatible API. The Colab route is built a bit differently because of Colab's rules, which I cover in the next section.

The harness looks at the generation of the rented GPU and picks the inference engine automatically.

There are three reasons for choosing Ollama on the T4:

The app runs only on 127.0.0.1 on my own PC. On top of that, I added two protections so that other websites cannot operate it without permission:

X-Harness) on POST requests When another website tries to send a request with a custom header, the browser blocks it. The app relies on that behavior.

This is the highlight of the article.

The first idea was to "expose the server started on Colab through a tunnel (cloudflared or ngrok) and use it from my PC."

However, Colab's FAQ prohibits offering web services to the outside and "connecting to remote proxies." On top of that, on the free tier, bypassing the notebook UI to work through a web UI is also prohibited.

Reference: Colab FAQ (Which activities are restricted in Colab?)

So I decided not to use a tunnel.

The first solution was to run the server only inside Colab (127.0.0.1) and use it from within the same notebook. Nothing is exposed to the outside.

But with this, I could not use it from the app on my PC.

In the end, I used Google's official Colab CLI. The app sends code with colab exec and receives the result. This let me chat from the app on my own PC without exposing the server.

The flow looks like this:

colab new -s llm-harness --gpu T4

colab exec -s llm-harness -f setup.py


colab stop -s llm-harness

This works thanks to two properties described in the official documentation:

exec calls β†’ a server started once can be reused I passed the chat content through environment variables (--env) instead of embedding it in the code. When I checked the Colab CLI source, the values were safely embedded using Python's repr.

The GPU options are T4 / L4 / G4 / A100 / H100. Which ones you can use depends on your plan.

I learned that it matters to design within the rules, rather than settling for "it works, so it's fine."

I actually ran it on a T4 with Colab Pro.

The GPU check came out as follows, and since it was a T4, Ollama was selected:

GPU: Tesla T4 15360 MiB compute 7.5 β†’ backend: ollama

The model was qwen3:8b.

(I asked both questions in Japanese; the above are translations.)

However, the two questions took 174.9 seconds.

It looked like it had stalled partway, so I checked nvidia-smi in a terminal and saw about 5.4 GB loaded into GPU memory. The slowness was because the model was being loaded onto the GPU on the first request only.

So I added two things:

OLLAMA_KEEP_ALIVE=-1 With this, replies come right away once "Ready" is shown.

The scary part about rented GPUs is getting billed because you forgot to stop one. I built the following into the Vast.ai route:

CONTAINER_API_KEY). My main API key is never passed to the instance Using the real Vast.ai or Colab costs money. So I built a "fake CLI" and a "fake LLM server" for testing.

I wrote fake vastai and fake colab commands in Python and swapped them in for the real ones with environment variables.

With browser automation (Playwright), the tests actually click through the UI and check "GPU search β†’ start β†’ chat β†’ stop" end to end.

These tests found a small bug where the text on the send button was wrapping vertically, and I fixed it.

To be honest, I have not tried the following two things for real yet:

That said, running it in the notebook version (Colab in the browser) has worked. That is the T4 result from the previous section.

colab exec from Google's official Colab CLI to chat from the app without exposing the server Design within the rules, rather than settling for "it works, so it's fine." That was the biggest lesson for me this time.

I handed the job of putting a shortcut on my PC to another agent (grokbot). Instead of my instructions for this task, grokbot read a different instruction file I had written on 11/17 (one for saving articles as drafts on Zenn and Qiita).

When handing work to an agent, pasting the text itself is more reliable than giving it a file name.

── more in #large-language-models 4 stories Β· sorted by recency
── more on @llm-harness 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/i-built-an-app-to-ru…] indexed:0 read:5min 2026-11-29 Β· β€”