Skip to main content
Ollama empowers users to work with large language models (LLMs) through its library of open-source models and its user-friendly API. This allows users to choose the best LLM for their specific task, whether it’s text generation, translation, or code analysis. Ollama also simplifies interaction with different LLMs, making them accessible to a wider audience and fostering a more flexible and efficient LLM experience. In this tutorial we will run Google Gemma with Ollama so that you can send queries via a REST API.

Quick start guide

  1. Prerequisites
  2. Starting a virtual machine with cudoctl
  3. Installing Ollama via SSH
  4. Using Docker to start a LLM API

Prerequisites

Starting a virtual machine with cudoctl

Start a virtual machine with the base image you require, here we will start with an image that already has NVIDIA drivers. You can use the CUDO Compute console to start a virtual machine using the Ubuntu 22.04 + NVIDIA drivers + Docker image or alternatively use the command line tool cudoctl To use the command line tool you will need to get an API key from the CUDO Compute console, see here: API key Then run cudoctl init and enter your API key. First we search to find a virtual machine type to start
Find an image:
After deciding on a machine type of epyc-milan-rtx-a4000 (16GB GPU) in the se-smedjebacken-1 data center and image ubuntu-2204-nvidia-535-docker-v20240214 we can start a virtual machine:

Installing Ollama via SSH

Get the IP address of the virtual machine
SSH into the virtual machine
Install ollama
Download and run Google Gemma LLM, then you can enter your prompt.
From the Ollama docs:

Using Docker to start a LLM API

If you had created a vm in the previous step delete it by running:
Create a text file with a command to start the Ollama docker container: start-ollama.txt
Create a virtual machine and include the command to add a start script -start-script-file start-ollama.txt:
Once the virtual machine is running you can curl the API to pull the model you require, here we use gemma:7b
Now it is ready to respond to a prompt: