当前位置:   article > 正文

【Tauri】(5):本地运行candle和 qwen 大模型,并测试速度_qwen1.5-0.5b怎么在cpu上运行

qwen1.5-0.5b怎么在cpu上运行

1,本地运行candle

关于candle项目
https://github.com/huggingface/candle

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

2,使用CPUP 运行qwen2-1.5大模型

cargo run --example qwen -- --model-id Qwen/Qwen1.5-0.5B-Chat --prompt 北京景点推荐
  • 1

因为网络原因,需要修改地址:

把 https://huggingface.co 修改成 https://hf-mirror.com/

    pub fn from_cache(cache: Cache) -> Self {
        let token = cache.token();

        let progress = true;

        Self {
            endpoint: "https://huggingface.co".to_string(),
            url_template: "{endpoint}/{repo_id}/resolve/{revision}/{filename}".to_string(),
            cache,
            token,
            progress,
        }
    }

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

~/cargo/registry/src/rsproxy.cn-0dccff568467c15b/hf-hub-0.3.2/src/api/sync.rs
在这里插入图片描述

否则会报错,访问不到:

     Running `target/debug/examples/qwen --model-id Qwen/Qwen1.5-0.5B-Chat --prompt '北京景点推荐'`
avx: true, neon: false, simd128: false, f16c: true
temp: 0.00 repeat-penalty: 1.10 repeat-last-n: 64
Error: request error: https://huggingface.co/Qwen/Qwen1.5-0.5B-Chat/resolve/main/tokenizer.json: Connection Failed: Connect error: Network is unreachable (os error 101)

Caused by:
    0: https://huggingface.co/Qwen/Qwen1.5-0.5B-Chat/resolve/main/tokenizer.json: Connection Failed: Connect error: Network is unreachable (os error 101)
    1: Network is unreachable (os error 101)

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

3,总结下

使用 candle还是非常方便的,使用另外一种方案运行大模型。
使用 cpu 速度就慢多了,开启量化的版本也慢:
在这里插入图片描述

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

闽ICP备14008679号