当前位置:AIGC资讯 > AIGC > 正文

Llama 3 五一超级课堂中实践llama3的部署,微调,量化优化部署学习总结:第一部分llama3部署

本次学习分享基于Llama3-Tutorial(Llama 3 超级课堂)分享,git地址如下

GitHub - SmartFlowAI/Llama3-Tutorial: Llama3-Tutorial(XTuner、LMDeploy、OpenCompass)gLlama3-Tutorial(XTuner、LMDeploy、OpenCompass). Contribute to SmartFlowAI/Llama3-Tutorial development by creating an account on GitHub.https://github.com/SmartFlowAI/Llama3-Tutorial/此外感谢InternStudio提供的大模型实训平台,还有学习群内小伙伴的相互帮助。

llama3-8b对话模型部署

步骤1:conda环境设置,命令如下

conda create -n llama3 python=3.10
conda activate llama3
conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 pytorch-cuda=12.1 -c pytorch -c nvidia

步骤2:下载已经训练好的llama3的权重

情况1:单独下载:通过从OpenXLab中获取权重

方法:安装 git-lfs 依赖

# 如果下面命令报错则使用 apt install git git-lfs -y
conda install git-lfs
git-lfs install

下载模型

git clone https://code.openxlab.org.cn/MrCat/Llama-3-8B-Instruct.git Meta-Llama-3-8B-Instruct

情况2:软链接 InternStudio 中的模型(用于InternStudio平台)

方法:

ln -s /root/share/new_models/meta-llama/Meta-Llama-3-8B-Instruct ~/model/Meta-Llama-3-8B-Instruct

步骤3:web demo环境部署

部署SmartFlowAI/Llama3-Tutorial

cd ~
git clone https://github.com/SmartFlowAI/Llama3-Tutorial

部署InternLM/XTuner时需要安装对应的库

cd ~
git clone -b v0.1.18 https://github.com/InternLM/XTuner
cd XTuner
pip install -e [all]

步骤4:运行Llama3-Tutorial的web对话测试服务

streamlit run ~/Llama3-Tutorial/tools/internstudio_web_demo.py \
  ~/model/Meta-Llama-3-8B-Instruct

访问对应的IP+端口地址来使用对话测试服务,效果和测试如下图,如果使用服务器的显存有限制可以使用量化后的llama-3-8B模型来测试对话服务,启动服务指令如下

streamlit run ~/Llama3-Tutorial/tools/internstudio_quant_web_demo.py \ ~/model/Meta-Llama-3-8B-Instruct

现有部署问题汇总

1. 显存问题:对于llama-3-8b模型部署时,在 InternStudio平台中的显存基础需求如下图所示

同理,在 InternStudio平台中部署量化版本模型时,显存基础要求如下

2. 部署后访问问题,对于InternStudio平台,参考Llama3-Tutorial/docs/hello_world.md at main · SmartFlowAI/Llama3-Tutorial · GitHubLlama3-Tutorial(XTuner、LMDeploy、OpenCompass). Contribute to SmartFlowAI/Llama3-Tutorial development by creating an account on GitHub.https://github.com/SmartFlowAI/Llama3-Tutorial/blob/main/docs/hello_world.md

 中的端口转发方法,其他平台也可参考类似解决方案

更新时间 2024-05-28