当前位置:   article > 正文

【candle】(3):安装rust环境,使用GPU进行加速,成功运行qwen的0.5b,4b,7b模型,搭建rust环境,配置candle,使用hf-mirror下载模型_qwen-4b

qwen-4b

1,视频地址

https://www.bilibili.com/video/BV1AF4m1E73d/

【candle】(3):安装rust环境,使用GPU进行加速,成功运行qwen的0.5b,4b,7b模型,搭建rust环境,配置candle,下使用hf-mir

https://gitee.com/fly-llm/candle-run-llm

3,关于candle项目

https://github.com/huggingface/candle

Hugging Face 使用rust开发的高性能推理框架。
语法简单, 风格与 PyTorch 相似。
CPU 和 Cuda Backend:m1、f16、bf16。
支持 Serverless(CPU)、小型和快速部署
支持 WASM,可在浏览器中运行模型。

3,rust环境搭建

安装软件文档:
https://www.rust-lang.org/tools/install

设置目录:


export RUSTUP_HOME=/root/autodl-tmp/cargo
export CARGO_HOME=/root/autodl-tmp/cargo

# 安装rust 软件
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

安装成功:

info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - rustc 1.76.0 (07dca489a 2024-02-04)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory (/root/autodl-tmp/cargo/bin).

To configure your current shell, run:
source "/root/autodl-tmp/cargo/env"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

执行命令:
source “/root/autodl-tmp/cargo/env”

# rustc -V
rustc 1.76.0 (07dca489a 2024-02-04)
  • 1
  • 2

4,下载 candle 项目

设置学术加速


cd /root/autodl-tmp/

# 设置hf 路径:
export HF_HOME=/root/autodl-tmp/hf_cache
# 下载项目
git clone https://github.com/huggingface/candle.git 

cd /root/autodl-tmp/candle

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

5,运行qwen-4b大模型


python3 download.py Qwen/Qwen1.5-4B
export HF_HOME=/root/autodl-tmp/hf_cache
cargo run --example qwen --features cuda -- --model 4b --prompt 北京景点推荐
  • 1
  • 2
  • 3
  • 4

6,运行qwen-0.5b的聊天模型


python3 download.py Qwen/Qwen1.5-0.5B-Chat
export HF_HOME=/root/autodl-tmp/hf_cache
cargo run --example qwen --features cuda -- --model-id Qwen/Qwen1.5-0.5B-Chat --prompt 北京景点推荐
  • 1
  • 2
  • 3
  • 4

7,运行效果

在这里插入图片描述

在这里插入图片描述

8,总结下

使用 candle还是非常方便的,使用另外一种方案运行大模型。
可以对模型进行加速。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/343748
推荐阅读
相关标签
  

闽ICP备14008679号