Running DeepSeek on Linux: A Step-by-Step Guide

Running DeepSeek on Linux: A Step-by-Step Guide

DeepSeek-R1 is an open-source LLM (language model) optimized for reasoning and problem-solving. We’ll use the distilled 1.5B-parameter version (“DeepSeek-R1-Distill-Qwen-1.5B”), which is the smallest CPU-friendly model (~1.1 GB disk). This guide shows how to install and run DeepSeek on Ubuntu or RHEL/CentOS using the simplest methods (Docker or prebuilt binaries). You will learn how to download the model and run a prompt as well as verifying output.

Prerequisites

  • Operating System: A distribution of Linux (Ubuntu/Debian or RHEL/CentOS). (Debian/Ubuntu users may find some steps easier.)
  • Memory & Storage: At least 8–16 GB RAM is recommended (the 1.5B model uses ~7 GB RAM, but 16 GB ensures smooth operation). Ensure at least 10–20 GB free disk space for the model and dependencies.
  • Software:
  • For Docker method: Install Docker (or Podman). Ensure the Docker service can run containers.
  • For Ollama method (no Docker): You need curl (for downloading the installer) and a Linux shell. Install curl (sudo apt install curl on Ubuntu); if not present.

Method 1: Using Docker

  1. Install Docker Engine:
  • Ubuntu/Debian: $ sudo apt update $ sudo apt install -y docker.io You should see output indicating Docker installed, for example: Setting up docker.io (20.x.x) ...
  • RHEL/CentOS: $ sudo yum install -y docker After installation, verify Docker is available: $ docker --version Docker version 24.0.x, build abcdef (Sample output: Docker version and build number.)
  • Start Docker: $ sudo systemctl start docker $ sudo systemctl enable docker $ sudo systemctl status docker Ensure the service is “active (running)”. (If not active, start it. Checking service status is similar to verifying any service.)
  1. Run the Ollama container: Ollama provides a Docker image with the CLI pre-installed. Launch it in the background with port 11434 exposed:
   $ sudo docker run -d --name deepseek-ollama -p 11434:11434 ollama/ollama

This outputs a container ID, e.g. tak12290s.... You can check it is running via docker ps.

  1. Download (pull) the DeepSeek model: Inside the running container, use Ollama to pull the 1.5B model.
   $ sudo docker exec -it deepseek-ollama ollama pull deepseek-r1:1.5b

Sample output (may take a few minutes):

   Downloading deepseek-r1:1.5b (1.1 GB)...
   [#####################################] 100% 1.1G/1.1G
   Download complete. 

This command saves the model files in the container (and to the mapped volume, if any).

  1. Run DeepSeek: Still inside the container, start the model and enter an interactive prompt. For example:
   $ sudo docker exec -it deepseek-ollama ollama run deepseek-r1:1.5b

The CLI will load the model. You will see a prompt like:

   DeepSeek-R1 (1.5B) is ready. Type your question below.
   > What is 2+2?
   4
   >

(The model responds with 4, as expected.) You can type any question after the > prompt. Press Ctrl+C or type exit to stop the session.

  1. Stop the container (optional): When done, exit the Ollama session and stop Docker:
   $ sudo docker stop deepseek-ollama

(This will shut down the container.)

Method 2: Using the Ollama CLI (no Docker)

  1. Install Ollama: Run the below in your terminal to install Ollama:
   $ curl -fsSL https://ollama.com/install.sh | sh

This downloads and executes the Ollama installer. You might see output like:

   Installing Ollama v0.X.Y...
   Ollama installed successfully.

Then verify the installation:

   $ ollama --version
   ollama version 0.X.Y

(You should see the version number of Ollama.)

  1. Download and run DeepSeek: Use the Ollama commands to pull and run the model:
   $ ollama pull deepseek-r1:1.5b

Sample output:

   Downloading deepseek-r1:1.5b (1.1 GB)...
   [#####################################] 100% 1.1G/1.1G
   Download complete.

Then start the model (this opens an interactive prompt):

   $ ollama run deepseek-r1:1.5b

You’ll see a prompt where you can type questions:

   DeepSeek-R1 (1.5B) is ready. Enter your query:
   > What is the capital city of Portugal?
   Lisbon.
   >

The model answers (in this case, “Lisbon.”). Press Ctrl+C when you’re done to exit the chat.

  1. List and remove models (free space): You can see which models are installed with:
   $ ollama list

Sample output:

   NAME              SIZE
   deepseek-r1:1.5b  1.1GB

To delete the model and free up space:

   $ ollama rm deepseek-r1:1.5b

Sample output:

   Removed model: deepseek-r1:1.5b

Troubleshooting + Tips

  • Command not found: Ensure to ran the installer or start the Docker service. You may need to re-open your terminal or add Ollama to your PATH.
  • Service not running: Start the Docker or Ollama service: e.g. sudo systemctl start docker or (for Ollama service) sudo systemctl start ollama.service.
  • Insufficient memory: The model uses several GB of RAM, make sure you have at least 8 to 16 GB RAM free or try swapping. (Smaller models may reqquire less memory.)
  • Performance tuning: Ollama uses all CPU threads by default setting. This can be restricted by setting the OLLAMA_NUM_THREADS environment variable. e.g export OLLAMA_NUM_THREADS=4 will use 4 threads. In case the model is running too slow or your system gets overloaded, this will help.
  • Container issues: If you are using Docker, check running containers (sudo docker ps). Make sure that the container name of (deepseek-ollama) matches what you used. If you change the docker run parameters, you may need to remove the old container first (sudo docker rm deepseek-ollama).

You should now have DeepSeek running locally. Simply rerun ollama run deepseek-r1:1.5b (or the Docker exec command) anytime you want to chat with the model. This setup works entirely offline and lets you verify each step with the sample outputs above.

Posts Carousel

Leave a Comment

Your email address will not be published. Required fields are marked with *

1 Comment

  • Julie
    June 13, 2025, 11:56 am

    Thanks for the article
    I've been looking for this.

    REPLY

Latest Posts

Most Commented

Featured Videos