llama.cpp部署(windows)

一、下载源码和模型

 下载源码和模型
# 下载源码
git clone https://github.com/ggerganov/llama.cpp.git

# 下载llama-7b模型
git clone https://www.modelscope.cn/skyline2006/llama-7b.git
 查看cmake版本:
D:\pyworkspace\llama_cpp\llama.cpp\build>cmake --version
cmake version 3.22.0-rc2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

 二、开始build

# 进入llama.cpp目录
mkdir build
cd build
cmake ..

build信息 

D:\pyworkspace\llama_cpp\llama.cpp\build>cmake ..
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.29.30137.0
-- The CXX compiler identification is MSVC 19.29.30137.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: D:/Git/Git/cmd/git.exe (found version "2.29.2.windows.2")
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- CMAKE_SYSTEM_PROCESSOR: AMD64
-- CMAKE_GENERATOR_PLATFORM:
-- x86 detected
-- Performing Test HAS_AVX_1
-- Performing Test HAS_AVX_1 - Success
-- Performing Test HAS_AVX2_1
-- Performing Test HAS_AVX2_1 - Success
-- Performing Test HAS_FMA_1
-- Performing Test HAS_FMA_1 - Success
-- Performing Test HAS_AVX512_1
-- Performing Test HAS_AVX512_1 - Failed
-- Performing Test HAS_AVX512_2
-- Performing Test HAS_AVX512_2 - Failed
-- Configuring done
-- Generating done
-- Build files have been written to: D:/pyworkspace/llama_cpp/llama.cpp/build

 本地使用Realease会出现报错,修改为Debug进行build,这里会使用到visual studio进行build

cmake --build . --config Debug

 build信息

D:\pyworkspace\llama_cpp\llama.cpp\build>cmake --build . --config Debug
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.11.2+f32259642
版权所有(C) Microsoft Corporation。保留所有权利。

  Checking Build System
  Generating build details from Git
  -- Found Git: D:/Git/Git/cmd/git.exe (found version "2.29.2.windows.2")
  Building Custom Rule D:/pyworkspace/llama_cpp/llama.cpp/common/CMakeLists.txt
  build-info.cpp
  build_info.vcxproj -> D:\pyworkspace\llama_cpp\llama.cpp\build\common\build_info.dir\Debug\build_info.lib
  Building Custom Rule D:/pyworkspace/llama_cpp/llama.cpp/CMakeLists.txt
  ggml.c

 在我本地D:\pyworkspace\llama_cpp\llama.cpp\build\bin\Debug目录下面产生了quantize.exe和main.exe等

 三、量化和推理

安装相关python依赖

python -m pip install -r requirements.txt

将下载好的llama-7b模型放入models目录下,并执行命令,会在llama-7b目录下面产生ggml-model-f16.gguf文件

python convert.py models/llama-7b/

对产生的文件进行量化

D:\pyworkspace\llama_cpp\llama.cpp\build\bin\Debug\quantize.exe ./models/llama-7b/ggml-model-f16.gguf ./models/llama-7b/ggml-model-q4_0.gguf q4_0

进行推理

D:\pyworkspace\llama_cpp\llama.cpp\build\bin\Debug\main.exe -m ./models/llama-7b/ggml-model-q4_0.gguf -n 256 --repeat_penalty 1.0 --color -i -r "User:" -f prompts/chat-with-bob.txt

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Llama.cpp 是一个虚构的编程文件名,因此无法给出具体的编程训练过程。然而,我可以简单介绍一下通常的编程训练方法。 首先,为了训练 Llama.cpp 这个程序,我们需要了解所使用的编程语言和开发环境。根据具体情况,我们可以选择使用 C++、Java、Python 或其他编程语言来编写代码。此外,我们需要安装相应的开发环境,如 Visual Studio、Eclipse 或者 PyCharm。 接下来,我们需要设定训练目标。这可能是一个具体的问题或任务,例如编写一个简单的加法程序、设计一个实现某种功能的小游戏或者开发一个完整的应用程序。 在开始编写代码之前,我们应该对问题进行分析和规划。这包括确定所需的输入和输出,设计程序的结构和逻辑,以及选择合适的数据结构和算法。 然后,我们可以开始编写代码。可以使用文本编辑器或集成开发环境来创建和编辑程序文件。根据训练目标,我们可以使用不同的编程概念和语法,如变量、函数、循环和条件语句,来实现所需的功能。 编写代码后,我们需要进行测试和调试。可以编写一些测试用例来验证程序的正确性,并运行程序进行测试。通过调试技巧和工具,我们可以找到并修复潜在的错误和问题。 最后,我们可以优化代码,提高程序的性能和效率。这包括减少资源消耗、优化算法和数据结构,以及优化代码的可读性和可维护性。 通过不断的实践和训练,我们可以逐渐提升编程技能,并学会更多高级的编程概念和技术。在编程的旅程中,理解问题、设计解决方案、编写代码、测试和调试是一个循环迭代的过程。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值