Install Ollama AI on Ubuntu Linux to Use LLMs on Your Own Machine
You might think getting an LLM up and running on your own machine would be an insurmountable task, but it's actually been made easy thanks to Ollama.
Jun 15th, 2024 6:00am by
Feature image by Albert-Paul from Pixabay/Ollama logo.

PrivateGPT is an AI project that allows you to ask questions about your own documents using large language models.
- Llama3: An openly available LLM from Meta
- Qwen2: A new series of LLMs from Alibaba
- Phi3: Lightweight LLMs from Microsoft
- Aya: Multilingual models in 23 languages
- Mistral: 7B model from Mistral AI
- Gemma: A lightweight LLM from Google DeepMind
nvidia-sma -aIf you receive an error and you know you have an NVIDIA GPU, make sure to install the required drivers. On a Ubuntu machine, you can check for available drivers with one of the following two commands, depending on your configuration: Desktop:
sudo ubuntu-drivers listServer:
sudo ubuntu-drivers list --gpgpuYou can then install the driver that’s the best match for your system with:
sudo ubuntu-drivers installAgain, if you don’t have an NVIDIA GPU, Ollama will still work — it’ll just be excruciatingly slow. If you just want to see how to get it up and running (even without an NVIDIA GPU), you can install it and run it, but know that it’s going to be hair-pullingly slow. Point made. Let’s install.
What You’ll Need
Here are the suggested minimum system requirements:- GPU: Nvidia Quadro RTX A4000
- Microarchitecture: Ampere
- Max GPUs: 2
- CUDA Cores: 6,144
- Tensor Cores: 192
- GPU Memory: 16GB GDDR6
- FP32 Performance: 19.2 TFLOPS
Installing Ollama
Installing Ollama is actually quite simple. Open your terminal app and run the following command:curl -fsSL https://ollama.com/install.sh | shIf the command reports that curl isn’t installed, you can add it with:
sudo apt-get install curl -yOr, if you prefer wget, you can download that installer with:
wget https://ollama.com/install.shIf you run the command with curl, the installer will automatically start. If you run it with wget, you’ll then have to give the file executable permissions with:
chmod u+x install.shYou can then run the script with:
./install.sh
Downloading a Model
Next, you’ll need to locate the LLM you want to use. Go to the Ollama library site and select the one you prefer. Let’s say you want to use the Llama3 LLM. Go back to the terminal app and issue this command:ollama run llama3Since this is the first time you’ve run the command, it will have to download the library. When the download is complete, you’ll see a new prompt that looks like this:
Send a message (/? for help)This is your prompt. Type a query such as:
What is Linux?If your have met the system requirements, you should receive a response fairly quickly. Otherwise, give it time to answer. When you’re done using Ollama, exit out of the prompt with Ctrl+D. You can use any of the listed LLMs that you want. Just remember to run this command:
ollama run LLM_NAMEReplace LLM_NAME with the name of the model you want to use. You could give anyone access to this machine and show them how to run their own queries via Ollama. Allow them to SSH into the system and they can conveniently access their new, locally installed AI from their desktop. And that’s all there is to installing and using a private AI on a local Linux machine. If you’re worried about privacy or any other issue that comes along with using public AI, this is a great option.
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube
channel to stream all our podcasts, interviews, demos, and more.