Artificial Intelligence 8 min read

Deploying DeepSeek R1:7b Model Locally with Ollama and Building AI Applications Using Dify

This tutorial explains how to set up Ollama for CPU or GPU environments, run the DeepSeek R1:7b large language model, and use the open‑source Dify platform to create and deploy a custom AI application, providing step‑by‑step commands and configuration details.

Cognitive Technology Team
Cognitive Technology Team
Cognitive Technology Team
Deploying DeepSeek R1:7b Model Locally with Ollama and Building AI Applications Using Dify

1. Ollama: Local Large‑Model Runtime

Ollama is an open‑source Go framework for running and managing large language models (LLM) locally. It supports both CPU and GPU environments.

1.1 CPU Environment Deployment

For personal developers or experiments, the CPU is sufficient to run DeepSeek R1:7b. Deploy with the following Docker command:

docker run -d -v /data/ollama:/root/.ollama -p 11434:11434 --name ollama registry.cn-hangzhou.aliyuncs.com/yilingyi/ollama

1.2 GPU Environment Deployment

For better performance, use a GPU. The steps below assume an NVIDIA GPU.

1. Install NVIDIA Container Toolkit

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \
    | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
    | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg]  https://#g' \
    | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update

2. Install the toolkit package

sudo apt-get install -y nvidia-container-toolkit

3. Configure Docker to use GPU

sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

4. Run Ollama with GPU support

docker run -d --gpus=all -v /data/ollama:/root/.ollama -p 11434:11434 --name ollama registry.cn

2. Running the DeepSeek Model

After Ollama is set up, download and start the DeepSeek R1:7b model:

docker exec -it ollama ollama run deepseek-r1:7b

The download may take some time; you can use this period to prepare the Dify platform.

3. Dify: AI Application Development Assistant

Dify is an open‑source LLM application platform that combines Backend‑as‑a‑Service (BaaS) and LLMOps, enabling rapid creation of production‑grade generative AI apps, even for beginners.

3.1 Install Docker‑Compose V2

mkdir -p ~/.docker/cli-plugins/
curl -SL https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose

3.2 Clone the Dify Repository

git clone https://github.com/langgenius/dify.git

3.3 Start Dify

Enter the Docker directory, copy the environment file, and launch the containers:

cd dify/docker
cp .env.example .env
docker compose up -d

Open the setup URL in a browser to create an admin account.

http://your_server_ip/install

4. Configuring DeepSeek in Dify

After Dify is running, add the DeepSeek R1:7b model via the console:

Log in to the Dify dashboard and go to Settings → Model Providers, add an Ollama configuration.

Create a new blank application of type "Chatflow".

In the LLM node, select "deepseek-r1:7b" and set the context variable to sys.query . Define a system prompt to control model behavior.

Preview and publish the application.

5. Summary

The guide demonstrates how to deploy the DeepSeek R1:7b model locally with Ollama, run it through Docker, and build a custom AI application using Dify, offering a complete, low‑cost stack for both individual developers and enterprises.

DockerAILLMDeepSeekGPUDifyOllama
Cognitive Technology Team
Written by

Cognitive Technology Team

Cognitive Technology Team regularly delivers the latest IT news, original content, programming tutorials and experience sharing, with daily perks awaiting you.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.