使用华为昇腾910B体验LMDeploy
【摘要】 环境介绍CPU:aarch64(鲲鹏920)内存:192GNPU:Huawei Ascend 910B (64G)操作系统:EulerOS 2.0 (SP8)CANN版本:CANN-8.0.RC3.alpha001
环境介绍
CPU:aarch64(鲲鹏920)
内存:192G
NPU:Huawei Ascend 910B (64G)
操作系统:EulerOS 2.0 (SP8)
CANN版本:CANN-8.0.RC3.alpha001
开始体验
克隆代码仓
git clone https://github.com/InternLM/lmdeploy.git
安装依赖
pip install transformers==4.41.0 timm -i https://mirror.sjtu.edu.cn/pypi/web/simple
pip install dlinfer-ascend==0.1.0.post1 -i https://mirror.sjtu.edu.cn/pypi/web/simple
安装lmdeploy
sed -i '/triton/d' requirements/runtime.txt && \
pip install -v --no-build-isolation -e . -i https://mirror.sjtu.edu.cn/pypi/web/simple
设置hf-mirrors环境变量
export HF_ENDPOINT=https://hf-mirror.com
LLM
体验代码(demo.py)
from lmdeploy import pipeline
from lmdeploy import PytorchEngineConfig
if __name__ == "__main__":
pipe = pipeline("internlm/internlm2_5-7b-chat",
backend_config = PytorchEngineConfig(tp=1, device_type="ascend"))
question = ["Shanghai is", "Please introduce China", "How are you?"]
response = pipe(question)
print(response)
运行
python demo.py
LLM 模型服务
将 --device ascend 加入到服务启动命令中
lmdeploy serve api_server --backend pytorch --device ascend internlm/internlm2_5-7b-chat
使用命令行与LLM模型对话
将--device ascend加入到服务启动命令中。
lmdeploy chat internlm/internlm2_5-7b-chat --backend pytorch --device ascend
VLLM
体验代码
from lmdeploy import pipeline, PytorchEngineConfig
from lmdeploy.vl import load_image
if __name__ == "__main__":
pipe = pipeline('OpenGVLab/InternVL2-2B',
backend_config=PytorchEngineConfig(tp=1, device_type='ascend'))
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg')
response = pipe(('describe this image', image))
print(response)
VLM 模型服务
将--device ascend加入到服务启动命令中。
lmdeploy serve api_server --backend pytorch --device ascend OpenGVLab/InternVL2-2B
使用命令行与LLM模型对话
将--device ascend加入到服务启动命令中。
lmdeploy chat internlm/internlm2_5-7b-chat --backend pytorch --device ascend
参考资料
官方文档:https://lmdeploy.readthedocs.io/zh-cn/latest/get_started/ascend/get_started.html
LMDeploy官方代码仓:https://github.com/InternLM/lmdeploy
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)