Skip to main content
This tutorial shows you how to set up Ollama, a platform for running large language models, on a Runpod GPU . By the end, you’ll have Ollama running with HTTP API access for external requests.

Requirements

  • A Runpod account with credits.

Step 1: Deploy a Pod

  1. Navigate to Pods and select Deploy.
  2. Choose a GPU (for example, A40).
  3. Select the latest PyTorch template.
  4. Under Pod Template, select Edit:
  • Under Expose HTTP Ports (Max 10), add port 11434.
  • Under , add a variable with key OLLAMA_HOST and value 0.0.0.0.
  1. Click Set Overrides and then Deploy On-Demand.

Step 2: Install Ollama

  1. Once the Pod is running, click the Pod to open the connection options panel and select Enable Web Terminal and then Open Web Terminal.
  2. Update packages and install dependencies:
  3. Install Ollama and start the server in the background:

Step 3: Run a model

Download and run a model using the ollama run command:
Replace llama2 with any model from the Ollama library. You can now interact with the model directly from the terminal.

Step 4: Make HTTP API requests

With Ollama running, you can make HTTP requests to your Pod from external clients. Try running the following commands, replacing OLLAMA_POD_ID with your actual Pod ID: List available models:
Generate a response:
Ollama returns streaming responses by default. To get a non-streaming response, add the stream: false parameter to the request body:
Congratulations! You’ve set up Ollama on a Runpod Pod and made HTTP API requests to it.
For more API options, see the Ollama API documentation.

Next steps