Ubuntu 部署ChatGLM3大语言模型

Ubuntu 部署ChatGLM3大语言模型

ChatGLM3 是智谱AI和清华大学 KEG 实验室联合发布的对话预训练模型。

源码:https://github.com/THUDM/ChatGLM3


部署步骤

1.服务器配置

Ubuntu 20.04

8核(vCPU) 32GiB 5Mbps GPU NVIDIA T4 16GB 硬盘 100GiB

CUDA 版本 12.2.2/Driver 版本 535.161.07/CUDNN 版本 8.9.4

查看CUDA版本:nvidia-smi

2.程序和模型文件

程序:

程序保存目录/home/ubuntu/ChatGLM3Test2,注意目录权限要可写

https://github.com/THUDM/ChatGLM3

模型:

建议从魔塔下载

模型保存目录/home/ubuntu/THUDM

https://www.modelscope.cn/models/ZhipuAI/chatglm3-6b/summary

注意:记得修改程序里面的模型目录

文件:composite_demo/client.py 第18行

3.Python环境

服务器安装Python3.10.0,参考https://blog.csdn.net/luobowangjing/article/details/137726093

安装Python3.10.0虚拟环境,参考https://blog.csdn.net/luobowangjing/article/details/131081787

复制代码
cd /home/ubuntu/ChatGLM3Test2
#安装虚拟环境依赖
pip install virtualenv

#*创建虚拟环境
virtualenv venv
#*激活虚拟环境
source venv/bin/activate

#退出虚拟环境
deactivate

4.安装依赖包

进入虚拟环境进行操作

前面安装虚拟环境时已经进入了。

复制代码
#设置pip源设置为清华大学的镜像,如果已设置就不用设置查看镜像源使用命令pip config get global.index-url
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
#如果版本是24.0就不用更新
python -m pip install --upgrade pip

#*安装项目依赖
pip install -r requirements.txt
#*安装Demo依赖,注意修改requirements.txt里面的huggingface_hub==0.19.4,否则运行demo会报错
pip install -r composite_demo/requirements.txt

5.运行测试

复制代码
streamlit run composite_demo/main.py --server.port 8502

6.配置服务器自启动

6.1.设置启动脚本 llmservice2.sh,vi llmservice2.sh,退出:wq

复制代码
#!/bin/sh
cd /home/ubuntu/ChatGLM3Test2
source venv/bin/activate
streamlit run composite_demo/main.py --server.port 8502

6.2.新建启动服务

​ 路径:/usr/lib/systemd/system/llmservice2.service

复制代码
[Unit]
Description=llmservice
After=network.target

[Service]
ExecStart=/home/ubuntu/llmservice2.sh

[Install]
WantedBy=default.target

7.服务自启动

复制代码
sudo systemctl enable llmservice2.service
sudo systemctl start llmservice2.service
sudo systemctl status llmservice2.service
sudo systemctl stop llmservice2.service
sudo systemctl restart llmservice2.service

8.启动成功截图

相关推荐
qq_401700416 小时前
Linux设备树详解
linux·运维·服务器
云梦谭6 小时前
让 Linux 主动连接 Windows:配置 Windows 11 SSH 服务端
linux·windows·ssh
刚入门的大一新生6 小时前
Linux-信号
linux·运维·服务器
GeW11 小时前
新质生产力路线图解读:数据库性能优化与Linux调优专场
linux
mounter62511 小时前
深入理解 gccrs:GCC 如何实现 Rust 编译器,以及编译 Linux 内核面临的挑战
linux·驱动开发·rust
垚垚学技术_聚焦云原生11 小时前
Ansible Playbook 进阶:when 条件、loop 循环、handlers 触发器落地
linux·ansible·自动化运维·devops
无足鸟ICT12 小时前
【RHCA+】type命令(判断命令类型)
linux·ssh·bash
咸鱼梦想家π12 小时前
Linux开发工具(下)
linux·运维·服务器
LHICOD12 小时前
Linux-1
linux·ip·vmware·虚拟机·cmd·ping
丰锋ff14 小时前
用户管理命令
linux·运维·服务器