Run ChatGPT on Linux: A Step-by-Step Guide with Ollama

Have you ever wanted to harness the power of ChatGPT directly on your Linux machine? With the innovative Ollama tool, this desire can become a reality. Ollama allows users to download and interact with a variety of open-source large language models (LLMs), similar to OpenAI’s ChatGPT. In this article, we’ll walk you through the setup process so you can get started quickly.

Setting Up Ollama on Your Linux System

Installing Ollama on your Linux operating system is a straightforward task that allows you to download and utilize different large language models with ease, eliminating convoluted manual processes.

To kick off the installation, open your terminal. You can do this by pressing Ctrl + Alt + T or by searching for “terminal” in your application menu.

Once the terminal window is open, type the command below to install the latest version of Ollama, which will configure your system for optimal use:

Important: Always review any script code before executing it. The complete source of this script can be found on GitHub.

curl https://ollama.ai/install.sh | sh

Follow the on-screen instructions to complete the installation. After this, Ollama will be successfully set up on your system.

Important Hardware Considerations

It’s worth noting that running large language models locally requires substantial computing power. For the best experience using Ollama with LLMs, having an Nvidia GPU or a powerful multi-core Intel/AMD CPU is highly recommended. If your system lacks the necessary hardware resources, don’t worry—you can still run LLMs with Ollama, although performance may be noticeably slower.

Discover and Install Large Language Models

Ollama provides access to numerous large language models. To explore the available options, head over to the “library” section of the official Ollama website.

Among the notable large language models you’ll find are:

  • Llama2 (developed by Facebook)
  • Orca2 (Microsoft’s customized Llama2)
  • Falcon (created by the Technology Innovation Institute)
  • OpenChat (a collection of open-source models trained on diverse datasets)

Once you’ve picked a language model to use with Ollama, download it to your system by executing the pull command. For example, to download the Orca2 model, you’d first need to ensure that Ollama is running:

ollama serve

Then pull the model using:

ollama pull orca2

After downloading, you can initiate the model with the ollama run command:

ollama run orca2

To close the model, press Ctrl + D on your keyboard.

Installing Oterm to Enhance Your Ollama Experience

For users seeking a more user-friendly interface, OTerm is an excellent GUI application for interacting with LLMs through Ollama. Unlike many tools requiring Docker or NodeJS, OTerm simply needs Python to function. Here’s how to set it up:

Step 1: Install Python

Open a terminal and follow the platform-specific commands to install both Python and Python3-venv:

For Ubuntu/Debian:

sudo apt update
sudo apt install python3 python3-venv

For Arch Linux:

sudo pacman -Sy python

For Fedora:

sudo dnf install python3 python3-virtualenv

For OpenSUSE:

sudo zypper install python3 python3-virtualenv

Step 2: Create a Python Environment

Once the required Python packages are in place, create and activate a Python virtual environment:

python3 -m venv python-env
source python-env/bin/activate

Step 3: Install Oterm

With the environment activated, install Oterm using pip:

pip install oterm

To launch Oterm, simply use:

oterm

Ensure that you have ollama serve running in a separate terminal. In the Oterm interface, select your preferred LLM and click “Create” to open a chat window. This is where you’ll engage with your AI-powered, self-hosted version of ChatGPT.

Conclusion: Unlocking the Power of AI on Linux

Running ChatGPT-style language models on Linux has never been easier, thanks to Ollama and Oterm. These tools not only streamline the installation process but also offer a flexible environment for engaging with state-of-the-art LLMs. Whether you’re a developer, researcher, or just an AI enthusiast, this setup provides an exciting platform to explore the possibilities of artificial intelligence. Enjoy your new AI-powered journey!

By Alex Reynolds

Tech journalist and digital trends analyst, Alex Reynolds has a passion for emerging technologies, AI, and cybersecurity. With years of experience in the industry, he delivers in-depth insights and engaging articles for tech enthusiasts and professionals alike.