简介

Koboldcpp 是一款基于 llama.cpp 构建的开源本地 AI 部署工具,能以简单的方式在本地设备上高效运行 GGUF 和 GGML 格式的 AI 模型。
如果GPU不可用或者性能弱,还可以用纯CPU跑(就是速度很慢)

AMD平台

需要使用 koboldcpp-rocm,项目地址:https://github.com/YellowRoseCx/koboldcpp-rocm
该项目发布了一些编译好的 release 包,但是只包含对一部分的A卡支持,本文所使用的780M核显不在其中,因此直接下编译好的是无法使用的。

需要自己编译。

准备工作

  1. 安装 HIP SDK,下载地址:https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html,这里我直接下载的最新版(v7.1.1)。然后安装。
  2. 官方HIP SDK默认没有添加对 780M核显(gfx1103)的支持,需要额外下一些库,地址:https://github.com/likelovewant/ROCmLibs-for-gfx1103-AMD780M-APU/releases,下载和所安装 HIP SDK版本一致的 gfx1103.7z,然后将压缩包内的文件解压复制到 rocm 目录,例如:
    把 rocblas.dll 复制到 C:\ProgramData\AMD\ROCm\7.1\bin,把 library 文件夹内所有文件 复制到 C:\ProgramData\AMD\ROCm\7.1\bin\rocblas\library
  3. 更新显卡驱动,版本不低于 25.1。
  4. 安装MSVC构建工具链,下载地址:https://visualstudio.microsoft.com/zh-hans/downloads/,下载的是 Visual Studio 2026 生成工具(也就是 Visual Studio installer),在installer中安装 MSVCv143-VS 2022C++x64/x86生成工具(v14.44-17.14)
    在这里插入图片描述
  5. 安装一个独立的 Python3.11, 版本不能低于3.10,太高了也不好,python的那些第三方模块的依赖特别脆弱,版本太高或太低都能直接嘎嘣死。不要复用其他软件的python环境,例如 Anaconda。
  6. 下载 w64devkit,w64devkit可以避免环境变量污染,地址:https://github.com/skeeto/w64devkit

开始编译

  1. 在 w64devkit.exe 所在目录,编辑 w64devkit.ini, 添加(取消注释)home 和 path type两个条目。
[w64devkit]
; home: Sets the HOME environment variable for the shell. Place a
; .profile in this directory to do further environment configuration
; using the shell itself.
;
; This path may be relative and reference environment variables using
; percent symbols, like a batch script. Variables will be expanded, a
; la ExpandEnvironmentStrings, and a relative path will be converted to
; an absolute path relative to this .ini file.
;
; path type: Sets $PATH according to one of three possible types.
; * inherit: inherit entire $PATH, prepending w64devkit's bin/ [default]
; * minimal: $PATH is w64devkit's bin/ and basic system directories
; * strict:  $PATH is only w64devkit's bin/
; Append +ccache for transparent ccache. Or prepend $W64DEVKIT_HOME/lib/ccache
; to $PATH, e.g. in your .profile.
;
; title: Sets the initial title for the new console window. This value
; may also contain environment variables.
;
home = ..\w64devkit_home
;home = %HOMEDRIVE%%HOMEPATH%
path type = minimal+ccache
;title = %USERNAME%@%COMPUTERNAME% [%W64DEVKIT_HOME% %W64DEVKIT%]
  1. 在 w64devkit_home 目录下新建一个 .profile 文件,内容如下:
export PATH="D:/Python311;D:/Python311/Scripts;D:/MyTools/Git/cmd;$PATH"
export HIP_PATH="C:/ProgramData/AMD/ROCm/7.1"
export CC="C:/ProgramData/AMD/ROCm/7.1/bin/clang.exe"
export CXX="C:/ProgramData/AMD/ROCm/7.1/bin/clang++.exe"
export CMAKE_PREFIX_PATH="C:/ProgramData/AMD/ROCm/7.1"

路径需要替换成自己实际路径。
3. 双击打开w64devkit.exe,此时拥有了一个新终端窗口,注意此时当前shell是 bash,相关命令语法既不是 cmd 的,也不是 powershell 的。
执行 python -m pip install cmake ninja pyinstaller==6.4.0 psutil customtkinter 安装python 第三方依赖。

  1. 克隆仓库,没有git工具也可手动下载
git clone https://github.com/YellowRoseCx/koboldcpp-rocm
cd koboldcpp-rocm
mkdir build
cd build
  1. 生成 makefile
cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLAMA_HIPBLAS=ON -DHIP_PLATFORM=amd -DGPU_TARGETS="gfx1103"`
  1. 构建, -j2 是并发线程数,可修改
cmake --build . --config Release -j2

运行 Koboldcpp

在 koboldcpp-rocm 目录下,新建一个 “启动.bat” 批处理文件,内容如下:

set PYTHON_PATH=D:\Python311
%PYTHON_PATH%\python.exe .\koboldcpp.py
pause

然后,双击“启动.bat”,选择模型,Launch!
在这里插入图片描述

模型下载站

https://huggingface.co/models

对话测试

在这里插入图片描述

Logo

免费领 150 小时云算力,进群参与显卡、AI PC 幸运抽奖

更多推荐