惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

博客园 - dudu

.NET CQRS 的实现中引入 ReadOnlyRepository 初试 .NET CQRS 开源库 LiteBus 什么是 Agentic ? 初试 Microsoft Agent Framework 初识 Microsoft Agent Framework:一句话介绍 ASP.NET Core 中读取 UserAgent 的正确姿势 记录一下对 ASP.NET Core Middleware 进行单元测试的代码 C# 实现通用的 IdEqualityComparer 用 Angular Signal Inputs 完成一个组件的重构 量子网络操作系统 QNodeOS 资料收集 Kubernetes 集群上部署 Open WebUI 在 Kubernetes 集群的 GPU 节点上部署 Ollama 尝试在 Kubernetes 集群上用阿里云 GPU 实例部署 Ollama + DeekSeek-R1 尝试使用阿里云计算巢部署 DeepSeek-R1 Angular 中依赖注入问题造成 Observable 订阅不更新 园子博客后台 Angular 升级:手工迁移至 Standalone Component Angular 中使用 ChildContent 记录 园子博客后台升级至 angular 19 后 eslint 9 迁移记录 学习大模型(LLM)的英文好文收集
阿里云 GPU 实例云服务器本地部署 DeepSeek R1
dudu · 2025-02-12 · via 博客园 - dudu

这篇博文记录一下使用阿里云 GPU 实例 ECS 基于 Ollama + Open WebUI 部署 DeepSeek R1 模型的过程。

选用的是阿里云 GPU 计算型 T4 加速型 ECS ,实例规格:ecs.gn6i-c8g1.2xlarge,CPU&内存:8核31G,GPU:NVIDIA T4,GPU显存:16G,操作系统:Ubuntu 24.04。

Ubuntu 安装 ollama

curl -fsSL https://ollama.ai/install.sh | sh

在安装过程中下面这个阶段停留时间比较长

Loading new nvidia-570.86.15 DKMS files...
Building for 6.8.0-51-generic
Building for architecture x86_64
Building initial module for 6.8.0-51-generic
EFI variables are not supported on this system
/sys/firmware/efi/efivars not found, aborting.

安装完成时的控制台输出

>>> NVIDIA GPU ready.
>>> The Ollama API is now available at 127.0.0.1:11434.
>>> Install complete. Run "ollama" from the command line.

curl 命令访问 11434 端口

curl 127.0.0.1:11434

得到下面的响应,说明 ollam 已正常运行

Ollama is running

我们这里部署 deepseek-r1 7b 模型,模型文件大小是4.7GB

拉取模型

ollama pull deepseek-r1:7b

但是经过多次尝试,这个 4.7G 的模型就是拉取不下来,详见博问 https://q.cnblogs.com/q/151681

后来几天尝试还是拉取不下来,看来不是临时性的网络问题,只能绕道而行,改为用 docker 拉取包含 deepseek-r1:7b 的 allama 镜像。

幸好 docker hub 上有现成的镜像 mazurkatarzyna/ollama-deepseek-r1-7b

docker pull mazurkatarzyna/ollama-deepseek-r1-7b:latest

然后用 docker compose 进行部署,docker compose 清单文件如下:

services:
  ollama:
    container_name: ollama
    pull_policy: if_not_present
    image: mazurkatarzyna/ollama-deepseek-r1-7b:latest 
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities:
                - gpu
    environment:
      OLLAMA_ORIGINS: "*"
      OLLAMA_HOST: "0.0.0.0"
  open-webui:
    image: ghcr.io/open-webui/open-webui:ollama
    container_name: open-webui
    volumes:
      - open-webui:/app/backend/data
    depends_on:
      - ollama
    ports:
      - 8080:8080
    environment:
      - 'ENABLE_OPENAI_API=False'
      - 'OLLAMA_BASE_URL=http://ollama:11434'
      - 'WEBUI_SECRET_KEY='
    extra_hosts:
      - host.docker.internal:host-gateway
volumes:
  open-webui: {}

docker compose 部署时出现下面的错误

Error response from daemon: could not select device driver "nvidia" with capabilities: [[gpu]]

需要通过下面的命令安装 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
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

安装之后 docker compose 部署成功,ollama 与 Open WebUI 容器成功启动。

通过 IP 地址访问服务器的 8080 端口就会看到 Open WebUI 的界面,创建账号后登录,就会看到默认选中了 deepseek-r1:7b,并且可以进行对话了。

部署就这么搞定了。