Run your first local AI model on Fedora with Ollama

A beginner guide to running a local AI model on Fedora Linux: install Ollama, check whether it uses your CPU or GPU, fix nonsense output, and tr…

You can run an AI chat model on your own Fedora laptop. Once the model is downloaded, Ollama generates responses on your computer without sending your prompts to a cloud model service. This article shows you how, using a tool called Ollama.

A local model is an AI model whose files you download once and run on your own computer. A prompt is the text you type to ask it something. Ollama is the program that downloads models, runs them and gives you a simple way to talk to them from the terminal.

By the end of this article you will have installed Ollama, run a model, checked that its answer is correct, and checked whether it runs on your CPU or your graphics chip. You do not need any AI experience. You only need to be comfortable copying commands into a terminal.

What you need

You need a Fedora laptop or desktop with free disk space: 4.7 GB for deepseek-r1:7b and 5.2 GB for qwen3:8b, plus room for Ollama itself and enough RAM to hold a model. In our tests, ollama ps showed 5.9 GB for Qwen3 8B at a 4096-token context and 6.5 GB at the 8192-token context we use in Step 4. The commands below were tested on this machine:

  • Fedora Linux 45 (KDE Plasma 6.8.3, kernel 7.3.4)
  • Lenovo ThinkPad T14 Gen 3, Intel Core i7-1265U (12 logical processors)
  • 32 GB RAM
  • Intel Iris Xe integrated graphics, no dedicated GPU
  • Ollama 0.24.0 from the Fedora repositories

A dedicated GPU is not required. A model with 7 to 8 billion parameters runs on an ordinary laptop CPU, just more slowly than on a GPU.

The steps also use curl, nano and jq. If any of them is missing, install them first (your favorite text editor can be used in place of nano, if desired):

sudo dnf install curl nano jq

The test laptop in KDE System Information:

KDE System Information on Fedora Linux 45 showing Plasma 6.8.3, kernel 7.3.4, 12 x Intel Core i7-1265U, 32 GiB RAM and integrated Intel Iris Xe graphics on a ThinkPad T14 Gen 3

Step 1: Install Ollama

Install the package from the Fedora repositories:

sudo dnf install ollama

On Fedora Linux 45, ollama is a small package that also installs ollama-base, ollama-rocm and ollama-vulkan. Vulkan is how Ollama reached the integrated GPU on our laptop, which matters in Step 3.

The package installs a systemd service but does not start it. Enable and start it in one command:

sudo systemctl enable --now ollama

Wait a few seconds, then check that the service is running:

systemctl status ollama --no-pager
ollama --version

You should see active (running) and a version number. If a command fails with "could not connect to ollama server" straight after a start or restart, wait five to ten seconds and try again; the server needs a moment to come up.

We will use DeepSeek-R1 7B and ask a question with an answer you can check yourself. The first run downloads the model, so it takes a few minutes:

ollama run deepseek-r1:7b "What is 17 times 6? Answer with just the number."

This model "thinks out loud" first: you will see its reasoning after a Thinking... line, then ...done thinking., then the answer. A working model ends with 102, because 17 × 6 = 102.

If the answer is wrong or unrelated, check where the model is running in Step 3.

To chat interactively instead, run ollama run deepseek-r1:7b with no prompt and type /bye to leave.

Step 3: Check whether it runs on CPU or GPU

While a model is loaded, ask Ollama where it is running:

ollama ps

Look at the PROCESSOR column. It shows 100% CPU, 100% GPU or a mix.

On our test laptop it showed 100% GPU even though the machine has no dedicated graphics card. The Fedora package turns on the Intel integrated GPU (through Vulkan), and on this system the output from that path was nonsense. Forcing the CPU gave correct answers.

If your answer was wrong and ollama ps shows GPU on an Intel integrated chip, hide the GPU from Ollama with a systemd drop-in:

sudo systemctl edit ollama

This opens a text editor on a file called override.conf. Type these lines at the top, above the line that says "Edits below this comment will be discarded", then save and exit (in nano: Ctrl+O, Enter, Ctrl+X):

[Service]
Environment="GGML_VK_VISIBLE_DEVICES=-1"

Restart the service, wait a few seconds, and repeat the test:

sudo systemctl daemon-reload
sudo systemctl restart ollama
sleep 8
ollama run deepseek-r1:7b "What is 17 times 6? Answer with just the number."
ollama ps

You should now get 102 and 100% CPU. Setting OLLAMA_VULKAN=0 alone did not help on our system, so use the line above.

This looks like a problem between Ollama's Vulkan backend and this graphics driver, not a mistake on your side. If your hardware is different, your result may differ too.

Step 4: Build a tuned model with a Modelfile

A Modelfile lets you save your own settings under a new model name. This step is needed for Step 5, which uses the model you build here. It builds on qwen3:8b, which you pull below, so creating the tuned model adds no second download. This one starts from Qwen3 8B, sets inference to use 10 CPU threads (our CPU has 12 logical processors), and sets an 8192-token context (how much text the model can hold in mind at once).

Create the Modelfile in the nano editor:

nano ~/Modelfile.qwen3-8b-10t

Paste the following text into ~/Modelfile.qwen3-8b-10t:

FROM qwen3:8b
PARAMETER num_thread 10
PARAMETER num_ctx 8192

Save with Ctrl+O and Enter, then exit nano with Ctrl+X.

Pull the base model, then build and run your version:

ollama pull qwen3:8b
ollama create qwen3-8b-10t -f ~/Modelfile.qwen3-8b-10t
ollama run qwen3-8b-10t "Reply with just OK."
ollama ps

The 10t in the name just means 10 threads. A larger context uses more RAM: on our laptop ollama ps showed 6.5 GB for this model at 8192. Speed depends on your CPU. Actual CPU use varies, and the best thread count depends on your processor, so compare speed and how responsive your laptop feels before keeping this setting.

Creating and starting a tuned model (this screenshot is from our Qwen3 14B test, so the model names differ from the commands above):

Terminal showing nano editing a Modelfile, ollama create qwen3-14b-10t succeeding, and ollama run starting the model

KDE System Monitor during an earlier DeepSeek run. The load is spread unevenly across the 12 logical processors; setting 10 threads does not mean a fixed 85% load.

KDE System Monitor showing varying usage across 12 CPU cores

Step 5: Let the model use tools with Pi

So far the model only talks. An agent framework such as Pi lets it act: Pi gives the model tools for reading and writing files, runs them for the model, and shows you the results. Install Pi from the Fedora repositories and check the version. We tested Pi 0.80.3:

sudo dnf install pi-coding-agent
pi --version

The newest pi-coding-agent package is currently available on Fedora Linux 45 (and Rawhide). On an older release, run dnf info pi-coding-agent first to see whether the package exists and which version you would get.

The package is a 16 MiB download and takes about 100 MiB on disk. The first time Pi starts, it downloads two small helper tools, fd and ripgrep.

When you run the test below, expect long output: in our test, Pi 0.80.3 printed the model's reasoning before each action.

Pi needs to know where Ollama is. If you have never used Pi, create its model configuration file. If you already have a models.json, do not replace it: add the ollama entry under your existing providers instead.

mkdir -p ~/.pi/agent
nano ~/.pi/agent/models.json

Paste the following, then save and exit:

{
  "$schema": "https://pi.dev/schemas/models.schema.json",
  "providers": {
    "ollama": {
      "baseUrl": "http://127.0.0.1:11434/v1",
      "api": "openai-completions",
      "apiKey": "ollama",
      "models": [
        {
          "id": "qwen3-8b-10t:latest",
          "name": "Qwen3 8B 10-Thread",
          "reasoning": false,
          "input": ["text"],
          "contextWindow": 8192,
          "maxTokens": 2048,
          "samplingParams": {
            "reasoning_effort": "none"
          },
          "cost": {
            "input": 0,
            "output": 0,
            "cacheRead": 0,
            "cacheWrite": 0
          },
          "compat": {
            "supportsDeveloperRole": false
          }
        }
      ]
    }
  }
}

The id shown above must match the model you built in Step 4. The apiKey is only a placeholder, because Ollama running on your own machine does not check it. Check that the file is valid JSON:

jq empty ~/.pi/agent/models.json && echo "Configuration is valid"

The model must support tool calls. Qwen3 does. Our installed deepseek-r1:7b returned a "does not support tools" error in Pi, so we used Qwen3 8B for the file-tool test.

Start Pi in an empty folder with the model you built in Step 4:

mkdir -p ~/pi-test && cd ~/pi-test
pi --model ollama/qwen3-8b-10t:latest

Then give it a small task with clearly separated steps:

Step 1: create result.txt with exactly three lines: one, two, three. Wait until the file is written. Step 2: only then read result.txt and tell me how many lines it has.

Pi wrote the file, read it back, and answered that it has exactly 3 lines. Exit Pi with /quit, or with Ctrl+D when the prompt is empty, then check the file from your normal shell:

cat ~/pi-test/result.txt

An earlier Pi session with a differently worded prompt: Pi writes the file, reads it, and the final answer is 3.

Pi session showing a write tool call creating result.txt, a read tool call, and the answer 3

One caution from our testing: our first attempt asked for both steps in one sentence, and Pi's read failed with "no such file" even though the file existed afterward. Spelling out the order, as above, worked. Small local models can trip on ordering, so keep tasks small and check the result.

Working with larger files

A local model can only read as much text as its context window holds, and a laptop CPU is slow on long inputs. In an earlier test we gave Qwen3 8B, with an 8K context, a full Fedora AI/ML SIG meeting log of about 86 KB. It timed out.

When we trimmed the same log to a short summary, Pi loaded the meeting-secretary skill, read the file and extracted the team, themes, links and action items. (That test was run on Fedora Linux 44.)

The lesson: for long documents, cut the input down first, for example by removing HTML and keeping only the parts you need, and ask for one small thing at a time.

Where to go next

You now have a local model running on Fedora, a way to check that its answers are right, and a way to see whether it uses your CPU or GPU. If the output looks like nonsense, check ollama ps before blaming the model.

Next, try the Fedora AI/ML SIG Agent Skills. They are a shared collection of ready-made instructions for AI tools, kept in the SIG’s skills-library repository. Each skill is a folder with a SKILL.md file that explains what it does and how to use it. Start with small, read-only inputs, as in the meeting-log example above.

Please tell the SIG what works and what does not on your hardware. Post your results on Fedora Discussion with the ai-ml-sig tag, or chat with the SIG on Matrix in #ai-ml:fedoraproject.org. If a skill itself has a bug, open an issue in the skills-library repository. Test results from different laptops help everyone.

Good luck with your installation, and enjoy running AI on your own Fedora machine.

AI assistance

This article was drafted with help from Claude (Anthropic), and the testing steps were guided by ChatGPT (OpenAI). The author ran and verified every step.

内容来自 LXer Linux News,版权归原作者所有。

阅读原文 ↗

来自「LXer Linux News」的更多文章

查看全部文章

用 HomepageTab 新标签页关注 RSS,打开浏览器就能看到更新。

安装 HomepageTab

相关阅读