Running Qwen2.5:14b on Free Colab T4 — Without Spending a Cent
Contents
The Short Version
Google Colab's free T4 (15GB of VRAM) can run Qwen2.5:14b, and the answers are a clear step up from the 1.5b model. The catch: a session lives at most 12 hours, and it disconnects after 90 minutes idle — and when it dies, you have to re-download the model. So it's great for trying things out and short-term use, not as a long-term service.
Setup
I used the google-colab-cli command-line tool, with my usual Gmail account. Start a new T4 session:
colab new --gpu T4 --session ollama-bigOnce it's up, check the GPU is working: nvidia-smi should show a Tesla T4, and torch.cuda.is_available() should return True.
Installing Ollama: Install zstd First
Running Ollama's official install script directly fails — it needs zstd to extract. Install it first:
apt-get install -y zstdThen the install script runs fine, and you end up with Ollama 0.40.19. Colab has no systemd, so the service has to be started manually in the background.
Pulling the Model: 9GB in 4 Minutes
ollama pull qwen2.5:14bA 9GB model, downloading at up to 238MB/s — pulled in a few minutes. After pulling, I tested a round of conversation: answers were fine, VRAM usage was about 9GB, with 5GB+ to spare.
External Access: Gradio Is the Only Reliable Door
Colab's runtime isn't reachable from outside, so you need to open a "door". Two attempts failed:
- cloudflared tunnel: it generates an address, but Cloudflare returns 403 — datacenter IPs are blocked.
- localhost.run: it connected, but gave no public address, so it was unusable.
In the end I used a Gradio chat page: a small program, a few dozen lines, that wraps the Ollama API as a web page and publishes it through Gradio's built-in share link. Open the link in a browser and you can chat — phone or computer.
One Gotcha: The Second Message Always Returns 400
After going live, I found the first message answered fine, but from the second message on, every request failed with HTTP 400. Checking the Ollama logs, the first request returned 200, and later requests were rejected within milliseconds.
The cause: Gradio 6's chat history is in dict format, and Ollama doesn't accept it as-is. The fix: before each request, clean all history messages down to the simplest plain-text {role, content} format. After the fix and a re-publish, two consecutive messages worked fine.
How to Keep the Model
Once a Colab session dies, the model is gone. Two ways to persist it:
- Google Drive: mount it and put the model directory there — next time, read it directly and skip the re-download.
- 115 Cloud Drive: a free account has 15GB total, with a 5GB max per file. The 14b model is 9GB, so tar it and split it in two (about 4.4GB each), upload both parts, and join them back together when you need them.
Summary
- A free T4 runs a 14b model just fine — great for trying out big models on a budget.
- Don't count on it staying online; when a session dies you rebuild it, so keep a one-click reinstall script handy.
- For long-term use, rent a GPU server — or accept running a small model on your own little VPS.
加载中…