How to Install DeepSeek Locally in Ubuntu

Learn how to install DeepSeek locally on Ubuntu with this step-by-step guide. Set up DeepSeek for offline AI development, including GPU support and web interface access.

How to Install DeepSeek Locally in Ubuntu
Photo by Gabriel Heinzer / Unsplash
DeepSeek: Leading the New Era of Artificial General Intelligence
Discover how DeepSeek is leading the AGI revolution with cutting-edge technology, industry applications, and ethical AI development. Learn what makes DeepSeek a global AI powerhouse.

DeepSeek is a powerful AI platform that offers state-of-the-art artificial intelligence capabilities, from natural language processing to computer vision. While DeepSeek provides cloud-based services, you can also install and run DeepSeek locally on your Ubuntu machine for offline use or custom development. This guide will walk you through the step-by-step process of installing DeepSeek on Ubuntu.


Prerequisites

Before starting, ensure your system meets the following requirements:

  • Operating System: Ubuntu 20.04 LTS or later.
  • Hardware:
    • CPU: 4 cores or higher (recommended).
    • RAM: 16 GB or more (32 GB for optimal performance).
    • GPU: NVIDIA GPU with CUDA support (optional but recommended for faster inference).
  • Software:
    • Python 3.8 or later.
    • pip (Python package manager).
    • Git (for cloning the repository).

Step 1: Update Your System

  1. Open a terminal window.

Run the following commands to update your system:

sudo apt update
sudo apt upgrade -y

Step 2: Install Dependencies

  1. Install CUDA and cuDNN (optional, for GPU support):

Install Git:

sudo apt install git -y

Install Python and pip:

sudo apt install python3 python3-pip -y

Step 3: Clone the DeepSeek Repository

Navigate to the cloned directory:

cd deepseek-local

Clone the DeepSeek GitHub repository:

git clone https://github.com/deepseek-ai/deepseek-local.git

Step 4: Set Up a Python Virtual Environment

Activate the virtual environment:

source deepseek-env/bin/activate

Create a virtual environment:

python3 -m venv deepseek-env

Step 5: Install Python Dependencies

  1. Install PyTorch (with CUDA support if applicable):

For GPU-enabled systems:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

For CPU-only systems:

pip install torch torchvision torchaudio

Install the required Python packages:

pip install -r requirements.txt

Step 6: Download the DeepSeek Model Weights

Move the weights file to the models directory:

mv deepseek-r1.pth models/

Download the pre-trained model weights:

wget https://deepseek-model-weights.s3.amazonaws.com/deepseek-r1.pth

Step 7: Configure DeepSeek

  1. Modify the following settings as needed:
    • device: Set to cuda if using a GPU, or cpu for CPU-only systems.
    • model_path: Ensure it points to the correct model weights file (e.g., models/deepseek-r1.pth).
    • Save and exit the file (Ctrl+O, Enter, Ctrl+X).

Open the configuration file:

nano config.yaml

Step 8: Run DeepSeek Locally

Open a new terminal window and test the API:

curl -X POST http://localhost:5000/api/v1/chat -d '{"message": "Hello, DeepSeek!"}'

You should receive a JSON response with the AI-generated reply.

Start the DeepSeek server:

python3 server.py

Step 9: Access DeepSeek via Web Interface (Optional)

  1. Open your browser and visit http://localhost:3000 to access the DeepSeek web interface.

Start the frontend server:

npm start

Install frontend dependencies:

npm install

Navigate to the web directory:

cd web

Install Node.js and npm:

sudo apt install nodejs npm -y

Troubleshooting

  1. CUDA Errors: Ensure your GPU drivers, CUDA, and cuDNN are correctly installed and compatible with your PyTorch version.
  2. Memory Issues: If you encounter out-of-memory errors, try reducing the batch size in the configuration file or using a smaller model.
  3. API Errors: Check the server logs for detailed error messages and ensure the server is running.

Conclusion

Congratulations! You’ve successfully installed DeepSeek on your Ubuntu machine. Whether you’re developing custom AI applications or running DeepSeek offline, this setup provides a robust foundation for exploring the power of artificial intelligence.

For more advanced configurations or to contribute to the DeepSeek project, visit the official GitHub repository: DeepSeek GitHub.