搭建Deepseek推理服务

发布于:2025-02-17 ⋅ 阅读:(115) ⋅ 点赞:(0)

概述:

本文介绍用Open webui + ollama搭建一套Deepseek推理服务,可以在web页面上直接进行对话。作为体验搭建的是Deepseek 7b参数版本

首先选择一个云厂商创建一台ubuntu系统的虚拟机,带公网IP,通过shell登录虚拟机完成以下操作;如果选择下通过docker安装,建议选择海外网络。

搭建方式一:docker搭建

安装docker:

sudo apt update

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common lrzsz -y

sudo curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

sudo apt update

sudo apt-get install docker-ce -y

安装open webui

启动open webui

docker run --network host -d -v ollama:/root/.ollama -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:ollama 

如果虚机是带GPU的可以通过下面命令启动

docker run --network host -d --gpus=all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:ollama

启动后可以通过docker ps 命令查看容器正常运行:

通过netstate -natp查看监听端口:

设置云平台安全组放通8080端口

启动过程会自动下载一些文件,通过命令docker logs open-webui -f 查看启动日志,等文件下载完即可通过:http://虚机ip:8080访问webui

第一次登录,根据自己情况输入名称,邮箱,密码完成本地注册

从选择模型下拉框中输入“deepseek-r1:7b” 进行下载,或者登录Ollama.com查找自己想要的模型

等模型下载完就可以进行对话,由于最近deepseek火热,模型下载速度很慢需要1-4个小时

搭建方式二:安装命令安装

 

sudo -i

#安装conda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

bash Miniconda3-latest-Linux-x86_64.sh

#创建python 3.11环境
export PATH=/root/miniconda3/bin:$PATH

conda create -n py311 python=3.11 -y

source activate py311

#安装ollama
curl -fsSL https://ollama.com/install.sh | sh

#安装open webui
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install open-webui

#启动ollama
nohup ollama serve |tee ./ollama.log &


#启动open webui
nohup open-webui serve --port 8080|tee ./webui.log 2>&1 &

可以通过tail -f webui.log 查看open webui启动日志,启动过程会自动下载一些文件,通过看日志确认文件下载完便可以通过8080端口访问,后续步骤如方式一


网站公告

今日签到

点亮在社区的每一天
去签到