一、背景
本地部署开源大语言模型,苦于常见笔记本和台式电脑的配置较低,运行不顺畅问题,因此拟通过内网Linux服务器来部署。本篇文章将全程记录部署全过程。供志同之士相互学习参考。
二、Centos7部署Docker
下载你想要的Docker版本,通过WinSCP传入内网服务器。具体部署操作如下:
# 将Docker放入指定文件夹并进行解压tar -zxvf docker-20.10.10.taz(这里是你的docker安装包的名字)# 解压之后将docker全部文件拷贝到根目录下的/usr/bin目录下sudo cp -p docker/* /usr/bin# 创建docker.service文件,实现开机自启动touch docker.service# 将以下内容粘贴到docker.service中[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network-online.target firewalld.serviceWants=network-online.target[Service]Type=notify# the default is not to use systemd for cgroups because the delegate issues still# exists and systemd currently does not support the cgroup feature set required# for containers run by dockerExecStart=/usr/bin/dockerdExecReload=/bin/kill -s HUP $MAINPID# Having non-zero Limit*s causes performance problems due to accounting overhead# in the kernel. We recommend using cgroups to do container-local accounting.LimitNOFILE=infinityLimitNPROC=infinityLimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process# restart the docker process if it exits prematurelyRestart=on-failureStartLimitBurst=3StartLimitInterval=60s[Install]WantedBy=multi-user.target# 把docker.service拷贝到根目录下的 /etc/systemd/system/ 目录sudo cp docker.service /etc/systemd/system/ # 对docker.service设置权限sudo chmod +x /etc/systemd/system/docker.service# 重新加载某个服务的配置文件sudo systemctl daemon-reload# 启动dockersudo systemctl start docker# 查看是否安装成功sudo docker --version
三、安装Python(含pip)
1、下载Python的Linux 版本,open-webui要求Python3.11.*版本。(下载Linux版本下的ollama实在太慢了,我只能多路径尝试。)
# 下载地址,选择tar.xz版本的安装包进行下载https://www.python.org/ftp/python/3.11.3/
2、使用WinSCP连接Linux服务器,将以上安装包传入/usr/python3目录(自定义)
# 在根目录下新建一个usr/python3mkdir /urs/python3/
3、解压、编译、创建软连接
# 进入目录cd /usr/python3# 解压,解压的python包是你自己的安装包名字xz -d Python-3.11.*.tar.xztar -xvf Python-3.11.*.tar# 进入解压并指明安装的Python路径cd Python-3.11.*./configure --prefix=/usr/local/python#注意:需要执行命令,避免pip3 install 的时候报错没有ssl模块,其实python下面是有的,没有的话先安装:1 yum install -y openssl-devel2 ./configure --with-ssl# 备注:也可直接用以下方式解决:pip install open-webui -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com# 编译安装make && make install# 软连接,便于直接用python3和pip3访问(centos7自带python2)ln -s /usr/local/python/bin/python3.11 /usr/bin/python3ln -s /usr/local//python/bin/pip3.11 /usr/bin/pip3# 检测安装情况python3 -Vpip3 -V
四、未完待续...