Run ollama on Google Collab or Kaggle
Project description
collab-ollama
Run Ollama on a Google Colab GPU and access it from your local machine via a Cloudflare Tunnel — no account or configuration required.
This is useful when models run too slow on your local machine, or when you need GPU-accelerated inference for synthetic data generation in large batches.
Quick Start
Run directly in a Colab cell with uvx — no install step needed:
!uvx collab-ollama
Or with a specific model:
!uvx collab-ollama -m gemma:2b
Alternative: pip install
If you prefer a traditional install:
!pip install collab-ollama
!collab-ollama
Specifying a Model
By default, phi3:mini is pulled and served. Use the -m / --model flag to choose a different model:
!uvx collab-ollama --model llama3:8b
!uvx collab-ollama -m gemma:2b
Once setup is complete, you'll see output like:
Setup is complete!
Base URL : https://xxxx-xxxxx-xxxxx-xxxxx.trycloudflare.com/v1/
API Key : No key required — leave it blank or use any string
Model : gemma:2b
Usage
Use the printed Base URL and Model with any OpenAI-compatible client. No API key is needed — leave it blank or pass any arbitrary string.
Ollama CLI
On your local machine, set OLLAMA_HOST to the base URL (without /v1/) and use the Ollama CLI as usual. Inference runs on the Colab GPU, but the experience feels local. Make sure you have the Ollama CLI installed locally.
export OLLAMA_HOST='https://xxxx-xxxxx-xxxxx-xxxxx.trycloudflare.com'
ollama run gemma:2b --verbose
You can pull and run any model that fits in the Colab GPU memory:
ollama pull llama3:8b
ollama run llama3:8b
Python (OpenAI SDK)
Ollama exposes an OpenAI-compatible API. Install the SDK and use the Base URL directly:
pip install openai
from openai import OpenAI
client = OpenAI(
base_url="https://xxxx-xxxxx-xxxxx-xxxxx.trycloudflare.com/v1/",
api_key="ollama", # any string works, or leave blank
)
response = client.chat.completions.create(
model="gemma:2b",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
],
)
print(response.choices[0].message.content)
Node.js (OpenAI SDK)
Install the SDK:
npm install openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://xxxx-xxxxx-xxxxx-xxxxx.trycloudflare.com/v1/",
apiKey: "ollama", // any string works, or leave blank
});
const response = await client.chat.completions.create({
model: "gemma:2b",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello!" },
],
});
console.log(response.choices[0].message.content);
How It Works
- Installs Ollama if not already present.
- Installs Cloudflared if not already present.
- Starts
ollama servewithOLLAMA_ORIGINS=*for broad CORS support. - Pulls the specified model (default
phi3:mini). - Opens a Cloudflare quick tunnel to
localhost:11434and prints the Base URL, API Key info, and Model name.
Requirements
- Colab: A Google Colab notebook with a GPU runtime.
- Local machine: Ollama CLI (for CLI usage), Python with openai, or Node.js with openai.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file collab_ollama-1.2.4.tar.gz.
File metadata
- Download URL: collab_ollama-1.2.4.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7010d97723d352a1c866358abd6e91cd8d4806624967851c5ba3fce2fece5406
|
|
| MD5 |
779f6f7afe0572b26e0cfbceb792b1ee
|
|
| BLAKE2b-256 |
0a2326aebd3de3200af9ac33f758bade2a96aa8177cf18ca6af24ed6d57d1cf3
|
Provenance
The following attestation bundles were made for collab_ollama-1.2.4.tar.gz:
Publisher:
publish.yml on zpratikpathak/collab-ollama
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
collab_ollama-1.2.4.tar.gz -
Subject digest:
7010d97723d352a1c866358abd6e91cd8d4806624967851c5ba3fce2fece5406 - Sigstore transparency entry: 1262670608
- Sigstore integration time:
-
Permalink:
zpratikpathak/collab-ollama@aac7e21435cae1f91b9b1c791572a4852d04ad69 -
Branch / Tag:
refs/tags/stable - Owner: https://github.com/zpratikpathak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aac7e21435cae1f91b9b1c791572a4852d04ad69 -
Trigger Event:
release
-
Statement type:
File details
Details for the file collab_ollama-1.2.4-py3-none-any.whl.
File metadata
- Download URL: collab_ollama-1.2.4-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb420f1883baaa1ccc778c9c9cbdaf7400197cdd4da30d0594c7408f90ff3acb
|
|
| MD5 |
359f8c63917a37d0540b63f09904d74c
|
|
| BLAKE2b-256 |
1410aae61ed1710671a6b04b9572d7e140d4a4bd5ce339cc5c6005b160dbc6ed
|
Provenance
The following attestation bundles were made for collab_ollama-1.2.4-py3-none-any.whl:
Publisher:
publish.yml on zpratikpathak/collab-ollama
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
collab_ollama-1.2.4-py3-none-any.whl -
Subject digest:
cb420f1883baaa1ccc778c9c9cbdaf7400197cdd4da30d0594c7408f90ff3acb - Sigstore transparency entry: 1262670617
- Sigstore integration time:
-
Permalink:
zpratikpathak/collab-ollama@aac7e21435cae1f91b9b1c791572a4852d04ad69 -
Branch / Tag:
refs/tags/stable - Owner: https://github.com/zpratikpathak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@aac7e21435cae1f91b9b1c791572a4852d04ad69 -
Trigger Event:
release
-
Statement type: