Skip to main content
You can get an ollama image running on a GPU in a few minutes. Get started by adapting the following fly.toml file:
Modify the app name and region to suit your preferences and save the file as fly.ollama.toml. Then you can launch the app:
There are a couple of things to note here:
  • The ollama image is a GPU image, so you need to specify a GPU size in the [[vm]] section.
  • Not all regions have GPUs available, refer to region GPU availability for more info
  • The [[mounts]] section is used to mount a volume to store the models. This is a good practice to keep the models separate from the app code.
  • The volume size in this config file is 10gb, that’s enough for small models. Change this value if you need more.
  • The --flycast flag creates a private IPv6 address for the app.
Finally, this only starts the ollama server; at this point you cannot interact with any models yet. To do so, you will have to pull in a model with this one easy, short, intuitive command:
This command will pull in the llama3.1 model. You can change the model name to suit your needs. At this point this model is now available to the internal network of the organization it is deployed in. You can access it using Flycast from this URL: http://<your-app>.flycast. Now that we have a functioning ollama with a model, we have to expose the ollama host to our app. One way to do this is to set the host as a secret:
To interact with our new AI friend, we will have to install the ollama package:
Now we can initialize the client:
From here we can start integrating it into our app:
When you re-deploy your app you should see llama’s answer:
You can check out this gist for the complete example app.