当前位置: 首页 > news >正文

如何在 Ubuntu 24.04 本地安装 DeepSeek ?

Install Deepseek on Ubuntu

在本地 Ubuntu 系统上安装 DeepSeek 可以让您在本地使用高级 AI 功能,从而消除对云服务的依赖需求。

What is DeepSeek?

DeepSeek 是一个先进的开源人工智能模型,专为自然语言理解和生成而设计。它提供了类似ChatGPT的强大功能。

Prerequisites:

  • A running Ubuntu 24.04 Instance
  • Stable Internet Connection
  • Minimum 8GB RAM (recommended 16 GB RAM and Multi GPU)
  • At least 20GB Free disk space
  • Basic understanding of terminal

废话不多说,让我们开始 Deepseek 的安装步骤。登录到 Ubuntu 24.04 系统,按照以下步骤操作。

1) Update Your System

强烈建议在您的 Ubuntu 系统上安装所有可用的更新。

$ sudo apt update && sudo apt upgrade -y

Install Updates For DeepkSeek Installation Ubuntu

安装完所有更新后,重新启动系统。

$ sudo reboot

2) Install Python and Git

我们需要 Python 3.8 或更高版本来安装 deepseek,最新版本 Python 3.12 默认可用。

$ sudo apt install python3 -y

验证是否安装了 Python 3.8 或更高版本

$ python3 --version

Python Version Check Ubuntu

安装 Python 包管理器 pip

$ sudo apt install python3-pip -y
$ pip --version

安装 Git 用于克隆存储库

$ sudo apt install git -y
$ git --version

Pip GIT Version On Ubuntu 24.04

3) Install Ollama

Ollama 是一个简化本地运行大型语言模型的平台,使用以下 curl 命令安装它:

$ curl -fsSL https://ollama.com/install.sh | sh
$ ollama --version

Download Ollama On Ubuntu 24.04

安装完成后,Ollama 服务将自动启动,使用下面的命令来验证状态。

$ sudo systemctl status ollama.service

Ollama Service Status Ubuntu 24.04

4) Download and Run the DeepSeek Model

安装好 Ollama 后,下载 DeepSeek 模型。根据您的需求,您可以相应地下载它们。

  • DeepSeek-R1-Distill-Qwen-1.5B
  • DeepSeek-R1-Distill-Qwen-7B
  • DeepSeek-R1-Distill-Qwen-14B
  • DeepSeek-R1-Distill-Qwen-32B
  • DeepSeek-R1-Distill-Llama-8B
  • DeepSeek-R1-Distill-Llama-70B

这些模型基于两个不同的模型家族:

  • Qwen-based models (ranging from 1.5B to 32B parameters)
  • Llama-based models (8B and 70B parameters)

要下载 R1- 7B 模型,请运行以下 ollama 命令

$ ollama pull deepseek-r1:7b

Download DeepSeek Model 7B Ubuntu Command Line

这个命令将下载并运行 DeepSeek 模型的 7B 版本,下载数据量大约为 4.7GB

同样,如果您想下载 R1-14B 型号,那么请运行

$ ollama pull deepseek-r1:14b

Download DeepSeek Model 14B Ollama Command

一旦模型下载完毕,您可以通过运行命令列出它们。

$ ollama list

List Downloaded DeepSeek Model Ubuntu Command Line

启动特定型号,比如: 7b, 运行以下命令

$ ollama run deepseek-r1:7b

输入您的查询,您将得到您的答案,示例如下:

Run DeepSeek Model On Ubuntu 24.04

使用 Ctrl+D 从模型提示符中退出。

5) Set Up the Web UI for DeepSeek

为了获得更友好的体验,您可以通过 web 界面与 DeepSeek 进行交互。

$ sudo apt install python3-venv -y
$ python3 -m venv ~/open-webui-venv
$ source ~/open-webui-venv/bin/activate

接下来,使用以下 pip 命令安装 Open WebUI

$ pip install open-webui

Pip Install Open WebUI Ubuntu 24.04

启动 Open WebUI 服务

$ open-webui serve

Start Open WebUI DeepSeek Ubuntu

打开浏览器,导航到 http://localhost:8080 访问界面

Create Admin Account for WebUI DeepSeek

Create your admin account, it will take us to Web UI screen, select the
DeepSeek model from the dropdown menu to start interacting with it.

创建管理员账户,从下拉菜单中选择 DeepSeek 模型,开始与之交互。

Select DeepSeek Model in Open WebUI Screen

为 Web UI 创建 Systemd 服务

要使 Open web 在系统引导时自动启动,需要创建 systemd 服务文件。

$ sudo vi /etc/systemd/system/open-webui.service

添加以下内容:

[Unit]
Description=Open WebUI Service
After=network.target[Service]
User=linuxtechi
WorkingDirectory=/home/linuxtechi/open-webui-venv
ExecStart=/home/linuxtechi/open-webui-venv/bin/open-webui serve
Restart=always
Environment="PATH=/home/linuxtechi/open-webui-venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"[Install]
WantedBy=multi-user.target

用您的实际用户名替换 linuxtech, 重新加载系统并启用服务:

$ sudo systemctl daemon-reload
$ sudo systemctl enable open-webui.service
$ sudo systemctl start open-webui.service

使用以下命令查看服务的状态:

sudo systemctl status open-webui.service

Systemd Service for WebUI DeepSeek

我的开源项目

酷瓜云课堂-开源知识付费解决方案

  • course-tencent-cloud(酷瓜云课堂 - gitee仓库)
  • course-tencent-cloud(酷瓜云课堂 - github仓库)

相关文章:

  • MacOS+VSCODE 安装esp-adf详细流程
  • Django缓存框架API
  • 【四川省专升本计算机基础】第一章 计算机基础知识(上)
  • apk 安装后提示该应用未安装
  • Vue 的双向绑定原理,Vue2 和 Vue3 双向绑定原理的区别
  • 两数之和(暴力+哈希查找)
  • 《AI大模型应知应会100篇》第50篇:大模型应用的持续集成与部署(CI/CD)实践
  • Linux内核视角:线程同步与互斥的原理、实现与锁优化策略
  • 网络安全的范式革命:从被动防御到 AI 驱动的主动对抗
  • Kotlin Android开发过渡指南
  • Kotlin Lambda优化Android事件处理
  • AI服务器的作用都有哪些?
  • PDF内容搜索--支持跨文件夹多文件、组合词搜索
  • Axure :列表详情、列表总数
  • Linux 磁盘初始化与扩容操作手册
  • Blender 初学者指南 以及模型格式怎么下载
  • 电子电器架构 --- 网关转发时延解析
  • GEC6818蜂鸣器驱动开发
  • UE5 Daz头发转Blender曲线再导出ABC成为Groom
  • 【Django】REST 常用类
  • 韩正出席庆祝中国欧盟建交50周年招待会并致辞
  • 娱见 | 为了撕番而脱粉,内娱粉丝为何如此在乎番位
  • 被炒热的“高潮针”:超适应症使用,安全性和有效性存疑
  • 演员扎堆音乐节,是丰富了舞台还是流量自嗨?
  • 旧宫新语|瑞琦:再探《古玩图》——清宫艺术品的前世与今生
  • 外交部发言人就澳大利亚联邦大选结果答记者问