用TensorRT-LLM跑通chatGLM_6B模型

本文讲述了如何使用GitLFS安装、构建TensorRT-LLMDocker镜像,配置Python环境,下载模型并转换为TensorRT格式,以及运行模型示例的过程。
摘要由CSDN通过智能技术生成

零、参考资料

NVIDIA官网
THUDM的Github
NVIDIA的Github

一、构建 TensorRT-LLM的docker镜像

git lfs install
git clone  https://github.com/NVIDIA/TensorRT-LLM.git
cd TensorRT-LLM
git submodule update --init --recursive
sudo make -C docker release_build
sudo make -C docker release_run

二、在docker镜像中配置并跑GLM模型

1、配置python环境

cd ./examples/chatglm
pip install -r requirements.txt
apt-get update
apt-get install git-lfs

2、从 HuggingFace 下载模型权重

git clone https://huggingface.co/THUDM/chatglm-6b chatglm_6b 
需要等一段时间 
cp chatglm_6b/tokenization_chatglm.py chatglm_6b/tokenization_chatglm.py-backup 
cp tokenization_chatglm.py chatglm_6b

3、将Hugging Face提供的GLM模型转换成TensorRT格式

python3 convert_checkpoint.py --model_dir chatglm_6b --output_dir trt_ckpt/chatglm_6b/fp16/1-gpu 

4、构建 TensorRT 引擎

# ChatGLM-6B: single-gpu engine with dtype float16, GPT Attention plugin, Gemm plugin 
trtllm-build --checkpoint_dir trt_ckpt/chatglm_6b/fp16/1-gpu --gemm_plugin float16 --output_dir trt_engines/chatglm_6b/fp16/1-gpu

5、运行例子

# Run the default engine of ChatGLM-6B on single GPU, other model name is available if built. 
python3 ../run.py --input_text "请输入你的问题" \
         --max_output_len 50 \
         --tokenizer_dir chatglm_6b \
         --engine_dir trt_engines/chatglm_6b/fp16/1-gpu
  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值