Llama3-Tutorial之Llama3本地Web Demo部署

本文详细介绍了如何在本地环境中配置Llama3,包括创建conda环境,安装所需库,从OpenXLab获取或使用预训练模型,以及部署WebDemo并通过XTuner运行。还涉及了VSCode中端口转发的设置,以实现在浏览器中访问Web对话界面。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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配置端口转发:

alt

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

alt

参考 vscode端口转发指南

本文由 mdnice 多平台发布

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lldhsds

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值