Llama3-Tutorial之Llama3本地 Web Demo部署

Llama3-Tutorial之Llama3本地Web Demo部署章节。

参考:
https://github.com/SmartFlowAI/Llama3-Tutorial

1. 环境配置

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. 下载模型

新建文件夹

mkdir -p ~/model
cd ~/model

方法一:从OpenXLab中获取权重:

  1. 安装 git-lfs 依赖:
# 如果下面命令报错则使用 apt install git git-lfs -y
conda install git-lfs
git-lfs install
  1. 下载模型

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

方法二:使用下载好的模型

软链接 InternStudio 中的模型

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

本文使用InternStudio进行实验,使用方法二。

3. Web Demo 部署

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

安装 XTuner 时会自动安装其他依赖:

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

运行 web_demo.py

(llama3) root@intern-studio-50014188:~# streamlit run ~/Llama3-Tutorial/tools/internstudio_web_demo.py ~/model/Meta-Llama-3-8B-Instruct

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.


  You can now view your Streamlit app in your browser.

  Network URL: http://192.168.230.228:8501
  External URL: http://192.168.230.228:8501

load model begin.
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████| 4/4 [00:36<00:00,  9.17s/it]
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
load model end.

vscode配置端口转发:

操作终端通过http://localhost:8501/打开web对话界面:

参考
vscode端口转发指南

本文由mdnice多平台发布


lldhsds
1 声望2 粉丝